Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using jquery.soap with VB.net web service #4

Closed
Velocedge opened this issue Apr 3, 2013 · 10 comments
Closed

Using jquery.soap with VB.net web service #4

Velocedge opened this issue Apr 3, 2013 · 10 comments
Labels

Comments

@Velocedge
Copy link

I'm trying to upgrade my clients that call a VB.net web service using jquery.soap that I just downloaded. I'm getting an error "Server did not recognize the value of HTTP Header SOAPAction: LMSLaunch". My JavaScript code looks like:

[code]
myParams = { course: course_int, lesson: lesson_int, etc..... }

$.soap({
url: 'www.server.com/Net/LMWAPI/service1.asmx',
namespaceQualifier: 'SCORM12/',
namespaceUrl: 'urn://service1.www.server.com', // don't really know what to put here
method: 'LMSLaunch',
params: myParams,
success: function (soapResponse) {
debugger
}
request: function (SOAPRequest) {
debugger
},
error: function (SOAPResponse) {
debugger
}
});
[/code]

In the web service I really have two different API's for the LMSLaunch method, one for RPC and another. With the "string params" removed for clarity the VB web service code looks like:

[code]
<WebService(Namespace:="SCORM12/" Description:="A .NET API")> _
Public Class Service1

<WebMethod(Description:="Launchs a SCO")> _
Public Function LMSLaunch(...string params...) As String

and

<SoapRpcMethod("SCORM12/LMSLaunchRPC", _
requestnamespace:="SCORM12/", _
responsenamespace:="SCORM12/"), _
WebMethod(Description:="Stub for RPC communication")> _
Public Function LMSLaunchRPC(...string params...) As String

[/code]

So, can you tell me (1) what I've done wrong and (2) what the namespaceUrl really should be?

@doedje
Copy link
Owner

doedje commented Apr 5, 2013

you might try adding appendMethodToURL: false to the options.....?

@Velocedge
Copy link
Author

Thanks for the reply, very much appreciated.

You know, I thought of that and was setting appendMethodToURL both in my JavaScript as well as forcing it in your jquery.soap.js file, but it didn’t seem to make any difference. I got started looking at that because at first I was getting a 404 error and looking at the URL it was ending in a net/lmwapi/service1.asmxLMSLaunch... which obviously wasn’t going to work.

I was able to capture the request package and compare. Here is the response package created by jquery.soap:

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body
<SCORM12/:LMSLaunch xmlns:SCORM12/="urn://service1.learnnet">
<SCORM12/:org_int>98</SCORM12/:org_int>
<SCORM12/:person_int>9</SCORM12/:person_int>
<SCORM12/:course_int>3895</SCORM12/:course_int>
<SCORM12/:lesson_int>0</SCORM12/:lesson_int>
<SCORM12/:sco_identifier></SCORM12/:sco_identifier>
<SCORM12/:test_int>915599</SCORM12/:test_int>
<SCORM12/:strData>0</SCORM12/:strData>
</SCORM12/:LMSLaunch>
/soap:Body
/soap:Envelope

And the one created by the webservice.htc behavior:

<SOAP-ENV:Envelope xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="SCORM12/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

SOAP-ENV:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/SOAP-ENV:Body
/SOAP-ENV:Envelope

Now, if I kill the namespace it makes the options look like the successful packed but of course there is no namespace and it fails.

<soap:Envelope /lns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/soap:Body
/soap:Envelope

Hopefully, this rambling will give you some ideas what I’ve done wrong.

@Velocedge
Copy link
Author

Also, is the namespaceUrl: 'urn://service1.www.server.com' correct? I'm not sure where that fits in.

@doedje
Copy link
Owner

doedje commented Apr 5, 2013

I think in your case namespaceQualifier should be 'tns' and namespaceUrl should be 'SCORM12/'...

and also try the option soap12: true

Just a quick response... Hope it helps

Remy

On 5 apr. 2013, at 21:15, Velocedge notifications@github.com wrote:

Thanks for the reply, very much appreciated.

You know, I thought of that and was setting appendMethodToURL both in my JavaScript as well as forcing it in your jquery.soap.js file, but it didn’t seem to make any difference. I got started looking at that because at first I was getting a 404 error and looking at the URL it was ending in a net/lmwapi/service1.asmxLMSLaunch... which obviously wasn’t going to work.

I was able to capture the request package and compare. Here is the response package created by jquery.soap:

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body
<SCORM12/:LMSLaunch xmlns:SCORM12/="urn://service1.learnnet">
<SCORM12/:org_int>98</SCORM12/:org_int>
<SCORM12/:person_int>9</SCORM12/:person_int>
<SCORM12/:course_int>3895</SCORM12/:course_int>
<SCORM12/:lesson_int>0</SCORM12/:lesson_int>
<SCORM12/:sco_identifier></SCORM12/:sco_identifier>
<SCORM12/:test_int>915599</SCORM12/:test_int>
<SCORM12/:strData>0</SCORM12/:strData>
</SCORM12/:LMSLaunch>
/soap:Body
/soap:Envelope

And the one created by the webservice.htc behavior:

<SOAP-ENV:Envelope xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="SCORM12/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

SOAP-ENV:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/SOAP-ENV:Body
/SOAP-ENV:Envelope

Now, if I kill the namespace it makes the options look like the successful packed but of course there is no namespace and it fails.

<soap:Envelope /lns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/soap:Body
/soap:Envelope

Hopefully, this rambling will give you some ideas what I’ve done wrong.

From: Remy Blom
Sent: Friday, April 05, 2013 6:04 AM
To: doedje/jquery.soap
Cc: Velocedge
Subject: Re: [jquery.soap] Using jquery.soap with VB.net web service (#4)

you might try adding appendMethodToURL: false to the options.....?


Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub.

@Velocedge
Copy link
Author

I’ve worked on this so long, I’ll call it progress...

I changed to tns and SCORM12 with soap12 set to true. The new error was:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: '/' is an unexpected token. The expected token is '>'.

So I took the namespace out hoping that it would sneak through and just recognize the LMSLaunch action by itself but no luck. Got the following:
System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action.

@doedje
Copy link
Owner

doedje commented Apr 5, 2013

Can you send me the soap request you sent in the last attempt? So I can compare it to the htc soap… It should look better now…

It's time for bed here in the Netherlands…. good luck

greets

REMY

@Velocedge
Copy link
Author

Here’s the latest for your morning reading pleasure...

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
soap:Body
<SCORM12:LMSLaunch xmlns:SCORM12="tns://SCORM12.learnnet">
SCORM12:org_int98/SCORM12:org_int
SCORM12:person_int9/SCORM12:person_int
SCORM12:course_int3895/SCORM12:course_int
SCORM12:lesson_int0/SCORM12:lesson_int
SCORM12:sco_identifier/SCORM12:sco_identifier
SCORM12:test_int915599/SCORM12:test_int
SCORM12:strData0/SCORM12:strData
/SCORM12:LMSLaunch
/soap:Body
/soap:Envelope

I’ll also attach a bunch of this in a file.

BTW, I really appreciate this. Thanks!

Steve
jquery.soap

SOAPRequest
{
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body
<SCORM12/:LMSLaunch xmlns:SCORM12/="urn://service1.learnnet">
<SCORM12/:org_int>98</SCORM12/:org_int>
<SCORM12/:person_int>9</SCORM12/:person_int>
<SCORM12/:course_int>3895</SCORM12/:course_int>
<SCORM12/:lesson_int>0</SCORM12/:lesson_int>
<SCORM12/:sco_identifier></SCORM12/:sco_identifier>
<SCORM12/:test_int>915599</SCORM12/:test_int>
<SCORM12/:strData>0</SCORM12/:strData>
</SCORM12/:LMSLaunch>
/soap:Body
/soap:Envelope
}
soapNamespace: "http://schemas.xmlsoap.org/soap/envelope/"
typeOf: "SOAPRequest"

webservice.htc

<SOAP-ENV:Envelope xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="SCORM12/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

SOAP-ENV:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/SOAP-ENV:Body
/SOAP-ENV:Envelope
"

jquery.soap without namespace

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/soap:Body<
/soap:Envelope>

tried to fake the thing out by hard coding: ... didn't work

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0
</LMSLaunch xmlns="SCORM12/">
/soap:Body
/soap:Envelope

soap:Reason<soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: '/' is an unexpected token. The expected token is '>'.
System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action.

last request:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
soap:Body
<SCORM12:LMSLaunch xmlns:SCORM12="tns://SCORM12.learnnet">
SCORM12:org_int98/SCORM12:org_int
SCORM12:person_int9/SCORM12:person_int
SCORM12:course_int3895/SCORM12:course_int
SCORM12:lesson_int0/SCORM12:lesson_int
SCORM12:sco_identifier/SCORM12:sco_identifier
SCORM12:test_int915599/SCORM12:test_int
SCORM12:strData0/SCORM12:strData
/SCORM12:LMSLaunch
/soap:Body
/soap:Envelope

@Velocedge
Copy link
Author

It’s working but I don’t totally understand why... or at least why this way.

I changed the parameters to an xml string and then wrapped that with the method (ie. myParams = '<' + method + ' xmlns="SCORM12">' + myParams + '</' + _trackAPI + '>'; ) so the request package looks like:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
soap:Body

<org_int>98</org_int>
<person_int>9</person_int>
<course_int>3895</course_int>
<lesson_int>0</lesson_int>
<sco_identifier></sco_identifier>
<test_int>915599</test_int>
0

/soap:Body
/soap:Envelope

Now that it’s working, I also noticed it’s an asynchronous call. Any reason why it can’t be a synchronous one?

Thanks,

Steve

@doedje
Copy link
Owner

doedje commented Apr 7, 2013

I am glad it is working now... Could you post that part of the code that is responsible for producing the working soapRequest? This way you're helping future users of $.soap that run into your problem. Thanx!

Why is it async? The popular answer would be, cause it's 2013? The technical answer is, because $.ajax is async. And $.soap uses $.ajax... There used to be a async: false option in $.ajax but:

As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().

Besides, I'd advise you to use async calls, since they don't block up the browser like sync does. It might need a change in your programming from linear to event-driven. But it will surely pay off. As a programmer, you can just continue with doing stuff in the page, while your browser is doing the $.soap call...

PS: I edited our previous posts to delete quoted emails due to reply-on-reply.... So this issue is now a bit better readable.

@doedje doedje closed this as completed Apr 7, 2013
@Velocedge
Copy link
Author

Sure... here’s the whole thing and you can edit it so it makes sense to subsequent readers.

var wsURI = 'http://Server_Name/net/LMWAPI/Service1.asmx'
var nameSpace = "SCORM12"

in body onload function:

$.soap({
url: wsURI,
namespaceQualifier: nameSpace,
appendMethodToURL: false,
soap12: true,
namespaceUrl: 'urn://SCORM12.learnnet',
request: function (SOAPRequest) {
//alert(SOAPRequest);
},
error: function (SOAPResponse) {
alert('SOAP Error ' + SOAPResponse);
}
});

in the call:

function makeRequest(_trackAPI, myParams) {

myParams = '<' + _trackAPI + ' xmlns="SCORM12">' + myParams + '</' + _trackAPI + '>'; // this was what made it work

$.soap({
method: _trackAPI,
params: myParams,
success: function (soapResponse) {
var x = soapResponse.toString();
prepValue(x);
}
}
});

Thanks for all your help. I have one more question but it’s different so I’ll open a new ticket.

sr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants