Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - ASP/ASP.NET/Web Services/Other
Forum to discuss building external web applications for SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ASP/ASP.NET/Web Services/Other | New ThreadView:  Search:  
 Author  Thread: Web Service Question
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jan 08 9:43 AM
I am developing a web service that increments a value in the main SLX Db and returns the number to the client. The concept is that everyone needing this number can get from the same web service whether they are a remote client, remote office or network user.

The web service works great when I call it with this URL from the host server and from a network machine:
http://SERVERNAME:3333/GetProjectNumber/Service.asmx/GetProjNumber

I can also call it with this URL from both machines, which allows SSL access from outside the firewall:
https://FRIENDLYURL.com/GetProjectNumber/Service.asmx?op=GetProjNumber

But when I use the 2nd url in my code to call the web service from the machine that is not the web server, I get this error:

A string literal was expected, but no opening quote character was found.

Here is the code from the SLX Client I am using:

Sub GetProjectNumberWebService(Sender)
Dim sUserID
If (pklStage.Text <> "Lead" ) AND txtProjNumber.Text = "" Then
Set objRS = objSLXDB.GetNewRecordSet
sUserID=application.BasicFunctions.CurrentUserID
strSQL = "Select DEFAULTSECCODEID as DEFSEC from sysdba.USERSECURITY Where USERID = '" & sUserID & "'"
objRS.Open strSQL, objSLXDB.Connection
sUserID="USID=" & sUserID & "&DEFSEC=" & objRS("DEFSEC") & "&ProjID=" & application.BasicFunctions.CurrentViewID
' sUserID="USID=" & sUserID & "&DEFSEC=" & objRS("DEFSEC") & "&ProjID=" & "2"
set objRS=nothing
set oXMLDoc = CreateObject("Msxml2.DOMDocument")
set oXMLHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
' set oXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP.3.0")
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")

call oXMLHTTP.open("POST", "https://freindlyURL/GetProjectNumber/Service.asmx/GetProjNumber", false)

call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
call oXMLHTTP.send(sUserID)
End If
End sub

sub HandleStateChange
Dim sMessage
On error resume next
if (oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText

call oXMLDoc.loadXML(szResponse)
If Err.Number<>0 then
msgbox Err.Description
End IF
if (oXMLDoc.parseError.errorCode <> 0) then
call msgbox (oXMLDoc.parseError.reason)
call msgbox (oXMLDoc.parseError.description)
msgbox "Project Number not generated: The Stage will not be changed. Please ensure you are connected to the internet and try again."
'call msgbox (oXMLDoc.parseError.reason)
else

If oXMLDoc.getElementsByTagName("string")(0).childNodes(0).text="" then
if (oXMLDoc.parseError.errorCode <> 0) then
msgbox "DD"
call msgbox (oXMLDoc.parseError.description)
End IF
msgbox "Project Number not generated: The Stage will not be changed. Please ensure you are connected to the internet and try again."
Else

sMessage = "Your new Project Number is " & oXMLDoc.getElementsByTagName("string")(0).childNodes(0).text
msgbox sMessage
txtProjNumber.text = oXMLDoc.getElementsByTagName("string")(0).childNodes(0).text
End If

end if
end if
End Sub





[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jan 08 10:39 AM
Well the problem is definitely the script to call the service, although I can't see what it is quite yet. I do know it is not the web service, or the URL to invoke the service from the outside. I just threw a quick C# app together and can call your service from here.

Why not avoid he script altogether and use a .NET extension to make the call? That is what I would do (but I hate script ). But I'll take another look at the code to see if I can see what's wrong.

-Ryan
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jan 08 7:35 AM
Ryan, I have not given up on my script, but I would like to look into using .net extensions in SLX. Is there a good walk through somewhere that outline the creation and deployment of .net extension from VS to SLX? Would these extensions sync to remotes? Any special config required on network users? Any advice always appreciated.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jan 08 10:20 AM
Hi Steve,

Yes, .NET Extensions *do* sync to remotes. They will make their way to all SLX users in the same way that any SLX plugin does. The SLX install already installs the .NET framework (v2.0) so there is nothing to deploy manually. You just create your DLL that does whatever you need and returns whatever is needed to a script and then just call it as needed. You add the DLL to the SLX Entension Manager and it sucks the DLL into the database. This will sync to remotes and will get extracted and run on each PC as it is used.

There is a short step-by-step walkthrough of a simple "Hello World" .NET extension here: http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=83

Of course, as you jump in, there are many in these forums that can help

-Ryan
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jan 08 4:42 PM
Nice. Exactly what I was after. Now I am looking for an example of calling a web service from a .dll in vb.net.. Still a small disconnect but I am getting close. I was involved in an earlier thread where a SOAP method and XMLHTTP were presented for consumining web services in SLX. I started this thread using the XMLHTTP method, but am leaning toward the .net extension now - powerful stuff. In the other thread the consensus was that the SOAP toolkit would be needed on each machine to use the code.. Does the end user's workstation consuming the web service with a .net extension need any additional components such as the soap toolkit?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jan 08 4:55 PM
Hi Steve,

Nothing extra to distribute - it's all in the .NET framework (which the SLX install makes sure is present on the pc and will install if missing).

-Ryan
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 6:51 AM
Hey Steve,

The cool thing is that within VS all you have to do is create a .net class library. Add a web reference. When you do this VS will generate the proxy classes for you. I would then create a simple class to call the WS proxy objects that implement IRunnable. If you want to call methods off of this class directly and not through the Run method, you can inherit from System.ComponentModel.Component (easiest way).

Mark
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 7:15 AM
Also wondering about the SLX Soap client control.. Is this a viable option that would distribute itself with the other plugins free of dependancies like the SOAP toolkit? Also wondering if anyone has a sample of how to use the control - can't seem to find any documentation.. thanks
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 7:35 AM
Hey Steve,

With the SalesLogix Soap Client Control, I really do not know. It is COM based and I would assume that it is installed when the client is installed. I like Ryan prefer to work outside of SalesLogix when it comes to these kinds of things. Is there an adoption issue with .net extensions with your client?

Mark
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 7:50 AM
The only thing I am hesitant about using a .net extension is that this is code that cannot be maintained within the SLX framework. Using a .net extension is not out of the question, but if SLX provides a control that will keep the source code within SLX I would prefer to go that route. I didn't even realize the control existed until a few days ago so I thought I should find out more..
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 8:03 AM
I understand. That point for me is actually a strength. Since I can use SCC for storage, create libraries that are provided in binary form and use a dev environment that allows me to be infinately more productive. But honestly it really is a personal choice and comfort zone thing.

[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 8:45 AM
Ok, I am trying write a .net class to call my web service but cannot get it quite right.. does anyone have a sample of calling a web service from an SLX .net extension? I can make Ryan's hello world sample work , but cannot seem to connect to my webservice with a .net extension..
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 10:07 AM
Making progress, but stuck.. I am using a .net extension to call my web service - I have it working with hardcoded values. In my .net extension I can get results with the following info, where I am passing my WS hard code values:
Public Overrides Function Run(ByVal Args() As Object) As Object

Dim ProjNoWebSvc As New com.contechstormwater.saleslogix.Service()
Dim sResult As String
sResult = ProjNoWebSvc.GetProjNumber("U6UJ9A00000J", "N6UJ9A00000K", "O5PEBA100012")


MessageBox.Show(sResult, ".NET MessageBox")
Return Nothing
End Function

My disconnect is how to pass 3 string values from the SLX client to the .net extension.. Do I need to modify this line to accept 3 values? Do I use globals from SLX? Sooo close..
Public Overrides Function Run(ByVal Args() As Object) As Object


Code from SLX:Sub Button1Click(Sender)
Dim ext ' this variable will hold the handle for the loaded .NET Extension

' instanciate the .NET Extension
ext = Application.Managed.Create("SLXExtension", "SLXExtension.Class1")

' run it (and pass any arguments)
' Application.Managed.Run ext, "Hello from Architect....."
Application.Managed.Run ext, "U6UJ9A00000J", "N6UJ9A00000B", "O4PEBA100012"

' destroy the loaded .NET Extension
Application.Managed.Destroy ext

End Sub

Thanks
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 10:33 AM
You certainly could use globals if you wanted. However, the "Args" passed into "Run" is an array. You can add your three values to an array and just pass it in to the call to Run.

In the script that launches the .NET Extension, change this line:

Application.Managed.Run ext, "U6UJ9A00000J", "N6UJ9A00000B", "O4PEBA100012"


to this:

Application.Managed.Run ext, Array("U6UJ9A00000J", "N6UJ9A00000B", "O4PEBA100012")


Then in the .NET Extension you'll grab each element of the array for your three values:

sResult = ProjNoWebSvc.GetProjNumber(Args(0), Args(1), Args(2))


Make sense?

-Ryan
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 10:37 AM
BTW, if you wanted to just return the value from the web service back to the SLX script, change the extension code to this:

Public Overrides Function Run(ByVal Args() As Object) As Object

Dim ProjNoWebSvc As New com.contechstormwater.saleslogix.Service()
Dim sResult As String

Return ProjNoWebSvc.GetProjNumber(Args(0), Args(1), Args(2))

End Function


and then the script that calls it to this:

Sub Button1Click(Sender)
Dim ext
Dim result

ext = Application.Managed.Create("SLXExtension", "SLXExtension.Class1")

result = Application.Managed.Run(ext, Array("U6UJ9A00000J", "N6UJ9A00000B", "O4PEBA100012"))
MsgBox "I am back in the SLX script! The WS result was: " & result

Application.Managed.Destroy ext

End Sub


Does that make sense?

-Ryan
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 10:43 AM
Did I mention I feel like the village idiot quite often on this forum? hehehe. Thanks for the syntax -I actually figured out the array/index thing but did not have the syntax to pass multiples - makes perfect sense now.

So I am in good shape - have my web service returning data on a remote server through the SLX extension. Now I am trying to move the .dll from a dev box, which is calling the actual webservice hosted remotely with no VPN connection. Major victory. But I moved compiled the .net extension on my dev machine and have attempted to move the clients dev machine to test.. So I moved the entire Bin\Release folder to D:\Program Files\SalesLogix\ folder on the clients dev machine. When I try to add the .dll in the SLX .Net extension manager it is telling me: Error: One or more dependencies of {Path to .dll} were not found...

Any idea what I might be missing? BTW - this is really great stuff - I appreciate the examples.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 10:55 AM
Sounds like something is missing (obviously ). Instead of moving the DLLs over and adding them to the other system, why not just bundle them? In the .NET Extension manager you can bundle the extension and then apply it to the other system just like any bundle.

-Ryan
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 11:00 AM
Ah, of course - it can be bundled. Actually I just realized my dev system in 7.2 and production is 7.0.. Could this be the problem? I added the reference 'sage.saleslogix.netextension.framework' from a 7.2 system and tried to move to a 7.0..
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 4:45 PM
Ok, soooo close. I have the code working on the clients network, but when I log onto a remote office machine with the client installed and try to run the code I get "Invalid Class String" on this line:

ext = Application.Managed.Create("SLXProjNoExt", "SLXProjNoExt.GetProjNoExt")

From the erroneous machine I can successfully browse to the web service and the all works well when directly on the clients network.. Any thoughts? I am trying to find other machines to test from..
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 08 4:59 PM
A few ideas...

1) Is the extension released to the user you're testing as? (Note: You do the releases for this in the Extension manager)

2) In the code, are you getting a GUID back in teh ext variable?

3) Try running the batch file in the SLX dir that is named something like "RegisterDotNetExtensions.bat". Sometimes that step has failed in the standard install and that batch will fix things.

-Ryan

[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Jan 08 8:39 AM
Problem persists, although I can call the web service from a seperate system (7.2 - diff. version even) with the .dll registered on it. The client's system and is 7.0.. Also able to connect from another machine vpn'd in.. so it seems to be machine specific
1. Only released to admin, logging in as admin
2. How do I check for the GUID?
3. Ran the batch file on the app server - didn't fix the remote client (logged on through VPN)

Also have a couple other questions regarding .net extensions:
1. How do service packs and upgrades, say from 7.0 to 7.2 affect .net extensions?
2. Has anyone deployed a .net extension that call a web service and used in production? Used with Remotes and remote office? Any suprises?
3. I would like to see if the user is connected to the internet before I call the web service.. any suggestions on the best way to do this?
Thanks
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Jan 08 6:51 AM
Hey Steve,

1. you change check for the guid by using the IsEmpty(guid) method
2. Service packs have no effect. I have seen problems when I have compiled something on 7.2 and could not get it running on 7.0 machines. I generally set up common folders for each of the major releases for the to core .net assemblies to compile against when a new major release comes out.
3. one way is to use the WebRequest object and try to get a external web site. I beleve there are some connection APIs available in the 2.0 framework, though I have not used any as of yet. I usually just wrap my WS call in a try {} catch block and bow out gracefully if it fails.

Mark
[Reply][Quote]
Leon Gort
Posts: 127
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Nov 08 6:49 PM
was there ever a solution to get this to work within SLX instead of using a .NET extension or is this the only solution? We have the exact same issue.

Thx
Leon
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Dec 08 6:17 AM
Same Issue, such as it is not working as an extension? I generally only workin in .net extensions if I can. Web services is one of the things that a definately do as a .net extension. There are com objects for making a http request but you are then in charge of the processing of the result. What exactly is happening/or not and did you code work when it was run outside of SalesLogix?

M
[Reply][Quote]
Leon Gort
Posts: 127
 
Re: Web Service QuestionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Dec 08 3:22 PM
Thanks Mark - turned out to be a lot more simple problem than it looked. Development was done on the same server as the web service so a simple case of adding http:// solved the issue (doh). It's been interesting reading though and I definitely need to start looking at .net extensions as a better solution for some cases.

Cheers,
Leon
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/22/2024 4:10:38 PM