doedje / jquery.soap Goto Github PK
View Code? Open in Web Editor NEWThis script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
This script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
Hello,
By default it seems the SOAPaction header is the same as the method option. I'm having a problem with this and don't know how to correct it properly. My code is below. The plugin is sending a SOAPAction header of GetWorkflowHistory but I need it to be http://nintex.com/GetWorkflowHistory. For the moment I'm working around the problem by editing the plugin code line 212 as below. Any help would be appreciated. How would I access the plugin's config options in line 212 instead of the global object literal I'm using?
$.soap({
url: 'http://foo/sites/uw2/_vti_bin/nintexworkflow/workflow.asmx',
method: 'GetWorkflowHistory',
appendMethodToURL: false,
namespaceQualifier: 'nin',
namespaceUrl: 'http://nintex.com',
//SOAPAction: 'http://nintex.com/GetWorkflowHistory',
params: {
fileUrl: 'http://gaga/gaga/gaga/gaga/gogo',
stateFilter: 'Running'
},
success: function (soapResponse) {
// do stuff with soapResponse
// if you want to have the response as JSON use soapResponse.toJSON();
// or soapResponse.toString() to get XML string
// or soapResponse.toXML() to get XML DOM
consoleLog(soapResponse.toString());
},
error: function (soapResponse) {
// show error
consoleLog("ERROR: " + soapResponse.toString());
}
});
Line 212 of jquery.soap.js:
req.setRequestHeader("SOAPAction", ($.myCompany.SOAPAction) ? $.myCompany.SOAPAction : action);
I am trying to make the following request:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<mul xmlns="http://calculus">
<t1>2</t1>
<t2>2</t2>
</mul>
</soap:Body>
</soap:Envelope>
With the following $.soap
$.soap({
method: 'mul'),
namespaceURL: 'http://calculus',
data: {
t1: '1',
t2: '1',
},
});
The namespace does not appair on the method unless I set
namespaceQualifier: 'xlmns',
noPrefix: true,
But the prefix still appairs in front of the xlmns="http://calculus"
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<mul xmlns:xlmns="http://calculus">
<t1>
1 </t1>
<t2>
1 </t2>
</mul>
</soap:Body>
</soap:Envelope>
Am I doing anything wrong? Is this the expected result?
Hello,
I am developing a phonegap 3.X application and I am trying to call a webservice written in .NET. The problem is when the success call back is fired I get a blank value.
Code that I am using to call the webservice is as follows
$.soap({
url : 'http://some_ip/WebService/WebServiceAndroid.asmx?op=',
method : 'GetServerTime',
SOAPAction: "http://tempuri.org/GetServerTime",
data : {
Key : 'xyz',
Name : 'rakesh'
},
beforeSend : function(SOAPRequest) {
alert(SOAPRequest);
},
success : function(soapResponse) {
alert('success ' + soapResponse);
},
error : function(SOAPResponse) {
alert('failed '+SOAPResponse);
}
});
beforeSend alert message seems to be fine with the message
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetServerTime>
<Key>xyz</Key>
<Name>rakesh</Name>
</GetServerTime>
</soap:Body>
</soap:Envelope>
success message gives me
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetServerTimeResponse xmlns="http://tempuri.org/">
<GetServerTimeResult/>
</GetServerTimeResponse>
</soap:Body>
</soap:Envelope>
What am i doing wrong here?
Also if I set url : 'http://some_ip/WebService/WebServiceAndroid.asmx?op=' to url : 'http://some_ip/WebService/WebServiceAndroid.asmx/', webservice fails. Is this normal?
image below shows the webservice request and response for soap 1.1
Hi, great plugin. really loved it.
Now when I tried using .toJSON()
xml2json returns an error at line 109:
Uncaught TypeError: Cannot read property 'length' of undefined
I believe it is because of line 365 in your plugin which returns:
return $.xml2json(this.content);
The structure of the data sent is:
#document.<soap:envelope>...
I fixed this by replacing line 365 by:
return $.xml2json(this.content.documentElement.outerHTML);
Is it something wrong with my SOAP sent?
The SOAPAction header is not overwritten if the option is given an empty string ('').
Hi,
Because of my web service I need to send the nil parameters like this:
< q0:data xsi:nil="true"/ >
instead of
< q0:data> < /q0:data >
I have been looking in your code and trying to do some changes in it without results. Could you tell me where I should start modifying? I thought it was in the 'toString()', this is what you send to the ws, right?
Thanks in advance.
line 201 SOAP.Client.Status = xhrReq.status;
can not get this status,it's NULL...
Hi,
This plug really saved my day. Everything is working like a charm! Thanks a lot and good work.
I thought I'd add a progress bar as finishing touch. Can't get it to work though: I'm unable to start the progress bar from within the $.soap call, as beforeSend doesn't seem to execute my DOM alterations.
I also gave it a try using pace.js (http://ortheme.com/pace-automatic-page-load-progress-bar/). Same thing...
Any insights?
Again, thanks for a great plug!
$.soap({
url: "http://127.0.0.1:3000/fake-soap-response.xml",
/*method: "HelloWorld",*/
params: "xml",
request: function(SOAPRequest) {
console.log("req: "+ SOAPRequest);
$('#request').text(SOAPRequest);
},
success: function(SOAPResponse) {
console.log(" success: "+ SOAPResponse);
$('#feedbackHeader').html('Success!');
$('#feedback').text(SOAPResponse.toString());
},
error: function(SOAPResponse) {
$('#feedbackHeader').html('Error!');
$('#feedback').text(SOAPResponse.toString());
}
});
Error: Unexpected Content: null
throw new Error("Unexpected Content: " + $.type(this.content));
I am new with this all things. I am using phonegap for mobile app in eclipse. I am getting the "400 - Bad Request".
jQuery version : jquery 1.10.2
jquery.soap version : 1.2.1
$.soap call :
$.soap({
url: 'http://beans.task.dis.com/TaskBean_ws/',
method: 'getUsrName',
params: {
userID: 18
},
success: function (soapResponse) {
document.write(soapResponse.toString());
},
error: function (SOAPResponse) {
document.write(SOAPResponse);
}
});
Response :
400 - Bad Request
Hi,
I'm trying to return an array from a success function inside a soap petition.
I'm receiving my response successfully so the response goes inside the 'success' function, I parse the XML and store in a array all the important data. Finally I wrote:
console.log(array)
return array
I can see it correctly in that console.log but in my HTML I have:
< script >
var array = mysoappetition()
console.log(array)
< /script >
And it shows an undefined object. I have searched about returning object (http://www.java2s.com/Tutorial/JavaScript/0220__Array/Returnanarrayfromafunction.htm) and it looks like it is OK.
Thank you in advance.
I really like this library, but was wondering if it is possible to set attributes for parameters. For example, the result I want looks like this:
<soap:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"\>
soap:Body
<GetAllMaterialDetailObjects xmlns:ns="http://www.c20g.org/vms/db/1.0"\>
</soap:Body>
</soap:Envelope>
The cursor parameter has attributes that I want to set. I assume that setting a namespace for a parameter is done similarly.
Is it possible to do this with the library as it is? If not, do you know of the simplest way to edit the library to handle parameter attributes?
Thanks in advance
hey doedje, could i use jquery.soap with jquery1.3 ?
I know,soap depended some jquery new feasure,but i do want use jq1.10.
so could i use low version jquery like jq1.3 with some patch ? thx.
Hi!
when doing soapResponse.toString() , the string has < and > instead of < and > characters.
and the soapResponse.toJSON() cannot be created correctly. Each letter of the xml is put as a property in a list.
However, if I replace the < and > by < and > and do soapResponse.toJSON(), the json object is correctly created.
What would be the solution to create the json correctly without having to replace the characters?
I am writing a function that gets a list of IDs to query my application server for information. Once I have the list, I send a SOAP request to the same method but with different data using a for loop:
for(var i = 0; i < ids.length; i++)
{
$.soap({
method: 'getGroupInfo',
data: {
arg0: ids[i]
},
elementName: 'tns:getGroupInfo',
success: function (soapResponse) {
// Do stuff
}
});
}
If I use the javascript debugger and step through the code, the request is sent, however, if I don't slow down the system, then Firefox shows no request sent to my server after the first request to get the ID list.
Array params handling seems to be bugged and applies the namespace twice. Example params:
{
"Subject": {
"fedoraObjectSubject": {
"pid": "demo:6"
}
},
"Options": {
"context": {
"item": ["A", "Z"]
}
}
}
Yields the following output:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<tns:BuildPipeline xmlns:tns="http://www.example.org/Pipeline/">
<tns:Subject><tns:fedoraObjectSubject>
<tns:pid>demo:6</tns:pid>
</tns:fedoraObjectSubject>
</tns:Subject>
<tns:Options>
<tns:context>
<tns:tns:item>A</tns:tns:item>
<tns:tns:item>Z</tns:tns:item>
</tns:context>
</tns:Options>
</tns:BuildPipeline>
</soap:Body>
</soap:Envelope>
[Error] TypeError: 'undefined' is not a function (evaluating '$.soap')
(anonymous function) (DynamicPage.aspx, line 314)
dispatch (jquery-1.10.1.min.js, line 5)
handle (jquery-1.10.1.min.js, line 5)
Have $.soap calls tied to click event as follows -
$('#sbutton').click(function() {
var webServiceUrl = '/xweb/secure/netFORUMXML.asmx';
var tokenSOAP = ['<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">',
'<soapenv:Header/>',
'<soapenv:Body>',
'<ns:Authenticate>',
'<ns:userName>someusername</ns:userName>',
'<ns:password>somepassword</ns:password>',
'</ns:Authenticate>',
'</soapenv:Body>',
'</soapenv:Envelope>'];
var tokenData = tokenSOAP.join('');
$.soap({
url: '/xweb/secure/netFORUMXML.asmx',
data: tokenData,
success: function(SOAPResponse) {
tokenResponse = SOAPResponse.toXML();
var activeToken = $(tokenResponse).find("Token").text();
alert(activeToken);
var jsonString = form_data_string;
jsonSOAP = ['<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">',
'<soapenv:Header>',
'<ns:AuthorizationToken>',
'<ns:Token>',
activeToken,
'</ns:Token>',
'</ns:AuthorizationToken>',
'</soapenv:Header>',
'<soapenv:Body>',
'<ns:ExecuteMethod>',
'<ns:serviceName>someservice</ns:serviceName>',
'<ns:methodName>somemethodname</ns:methodName>',
'<ns:parameters>',
'<ns:Parameter>',
'<ns:Name>jsonData</ns:Name>',
'<ns:Value>',
jsonString.split('{').join('[|').split('}').join('|]'), // because it uses {} to denote parsed variables
'</ns:Value>',
'</ns:Parameter>',
'</ns:parameters>',
'</ns:ExecuteMethod>',
'</soapenv:Body>',
'</soapenv:Envelope>'];
var soapData = jsonSOAP.join('');
$.soap({
url: '/xweb/secure/netFORUMXML.asmx',
data: soapData,
success: function(SOAPResponse) {
alert('yeah, baby....');
},
error: function(SOAPResponse) {
console.log(SOAPResponse.toString());
}
});
},
error: function(SOAPResponse) {
console.log(SOAPResponse.toString());
}
});
});
Hi,
i have a Problem and nothing i do would help me. Sorry in this case for my bad english.
My Problem is:
I have coded an Cordova App with an simple execution for an existing WebService.
I have implemented
$.soap({
url: 'http://wsf.cdyne.com/WeatherWS/Weather.asmx/',
method: 'GetCityWeatherByZIP',
namespaceQualifier: 'ns1',
namespaceUrl: 'http://ws.cdyne.com/WeatherWS/',
params: {
ZIP: '3',
},
success: function (soapResponse) {
// do stuff with soapResponse
// if you want to have the response as JSON use soapResponse.toJSON();
// or soapResponse.toString() to get XML string
// or soapResponse.toXML() to get XML DOM
alert ("GEHT");
},
error: function (SOAPResponse) {
alert (SOAPResponse);
// show error
}
});
The WebService i will to get work with is : http://www.service-repository.com/operation/show?operation=GetCityWeatherByZIP&portType=WeatherSoap&id=58
The Issue that i get is : Request format is invalid : text/xml; charset:UTF-8.
Can any one help with that issue?
I would like to use this plugin to access a service that requires a binary token to secure the request. Is it possible to attach such a token with jquery.soap?
Thanks so much!
Nate
Hello,
I am having an issue invoking from my SOAP service. We want to pass a value into our SOAP service and get the data back for that record. I have attached screen shots of what we need to do, but more or less, I need to know how pass our value into the jquery.soap in order to get the XML back from the SOAP. BTW, this plugin is awesome. Much appreciated.
Here is my code below. I don't think it is correct for what we need it to do.
$.soap({
url: 'http://myservice.mysite.com/myservice.asmx/',
//method: 'ConnectedToDatabase', // this is a simple bool. this works
method: 'GetMembership', //Need to get THIS Working.
namespaceQualifier: 'xlmns',
namespaceUrl: 'http://tempuri.org',
params: {consituentId: 123456789}, //Don't know if I am doing this correctly
success: function (soapResponse) {
console.log (soapResponse.toString());
// do stuff with soapResponse
// if you want to have the response as JSON use soapResponse.toJSON();
// or soapResponse.toString() to get XML string
// or soapResponse.toXML() to get XML DOM
},
error: function (SOAPResponse) {
console.log("well that was an error");
// show error
}
});
As you can see below (click on the image for larger view), we want to pass an ID into our textbox and then get the value back the data for the record.
Eventually this will be JSON, BUT for now, consuming a SOAP service would be a great proof of concept. Any and all help is greatly appreciated.
Hi, it seems that xml header is missing from request, look there is no <?xml version="1.0" encoding="UTF-8"?>
:
[paul@oldchr ~]$ sudo nc -l -p 80 -v
Connection from 192.168.0.100:46252
POST / HTTP/1.1
Host: 192.168.0.100
Connection: keep-alive
Content-Length: 447
Origin: file://
SOAPAction: ...
Content-Type: text/xml; charset=UTF-8
Accept: application/xml, text/xml, */*; q=0.01
X-Requested-With: com.phonegap.helloworld
User-Agent: Mozilla/5.0 (Linux; U; Android 4.3; en-us; Android SDK built for x86 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Accept-Encoding: gzip,deflate
Accept-Language: en-US
Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><mns:login xmlns:mns=... soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><user xsi:type="xsd:string">...</user><password xsi:type="xsd:string">...</password></mns:login></soap:Body></soap:Envelope>
I'm using latest jquery.soap and jquery 1.10.2.
Hello,
I would like to have a processing overlay appear to the user when jquery.soap is communicating. I can get the following ajaxStart / ajaxStop method to work with mockjax in my application, but when I switch back to jquery.soap (which otherwise is communicating properly), no luck:
http://stackoverflow.com/questions/1964839/jquery-please-wait-loading-animation/1964871#1964871
Is there a fix, workaround or another solution for this desired feature?
Thanks!
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?
When we try to send NULL parameters trough a SOAP request it fails.
The error shown in FireBug is the following:
TypeError: params is null
if(params.constructor.toString().indexOf("Array") != -1) {// type is array
This page shows how to handle NULL parameters: http://technet.microsoft.com/en-us/library/ms190796%28v=sql.105%29.aspx
Congratulations for the great library ! I was trying to install the library using bower (http://bower.io/) but I was unable to find the package to install when executing:
bower search jquery.soap
I propose adding the library to bower repositories, so the library could be easily installed in new project.
hi, i tried the following but i keep getting Error: 500 bad request.
jQuery.soap({`
url: 'http://www.OpenLigaDB.de/Webservices/Sportsdata.asmx?WSDL',
method: 'GetMatchdataByGroupLeagueSaison',
appendMethodToURL: false,
namespaceURL: 'http://msiggi.de/Sportsdata/Webservices',
data: {
gorupOrderID: 1,
leagueShortcut: 'PL',
leagueSaison:'2014'
},
success: function (soapResponse) {
console.log(soapResponse.toXML());
// do stuff with soapResponse
// if you want to have the response as JSON use soapResponse.toJSON();
// or soapResponse.toString() to get XML string
// or soapResponse.toXML() to get XML DOM
},
error: function (SOAPResponse) {
// show error
}
});``
adding options to authenticate SOAP request by basic HTTP authentication.
info: http://en.wikipedia.org/wiki/Basic_access_authentication
easy to do, just redoing $.ajax request:
var xhr = $.ajax({//see http://api.jquery.com/jQuery.ajax/
type: "POST",
url: this.Proxy,
dataType: "xml",
processData: false,
data: content,
contentType: contentType + "; charset=" + this.CharSet,
beforeSend: function(req) {
// here is change HTTP authentication added
req.setRequestHeader("Authorization", "Basic XXX");
req.setRequestHeader("Method", "POST");
req.setRequestHeader("SOAPServer", SOAPServer);
if (contentType === SOAPTool.SOAP11_TYPE) {
req.setRequestHeader("SOAPAction", action);
}
}
});
I am hoping you can help me with this issue I am having.
I am just trying to use jquery.soap to call this web service: http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit
I tried to use the jquery.soap demo page that is provided.
The error I got was: Request format is invalid: text/xml; charset=UTF-8
The settings I used for the demo page are:
url: http://www.w3schools.com/webservices/tempconvert.asmx/
method: CelsiusToFahrenhei
appendMethodToURL: checked
params: XML String
The Result that I see is: Request format is invalid: text/xml; charset=UTF-8.
If you have time, can you take a look at getting jquery.soap call that sample temperature web service?
thanks,
David
This is more of an issue with jQuery.ajax than with your code, but I noticed on large XML responses sent from my services HTTP transport compression started to kick in and previously working SOAP requests started to cause JavaScript errors due to the "xhr" var not being defined correctly, causing parts of the "xhr.always" function to fail. I've attempted to modify the "Accept-Encoding" in both the jQuery ajax "headers" and "beforeSend" sections, but the value appears to either be read only or overridden by the browser on send.
Partial packet sniffer example output below:
POST /service_api/cgi-bin/Generic_SOAP_Handler.pl HTTP/1.1
Host: [removed]:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: application/xml, text/xml, */*; q=0.01
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: text/xml; charset=UTF-8
Method: POST
SOAPAction: BuildPipeline
X-Requested-With: XMLHttpRequest
Referer: http://[removed]:8080/service_api/
Content-Length: 512
Cookie: s_lv=1355332687625; __qca=P0-266234781-1355332659993
Authorization: Basic aGEgaGEsIEkgbWFkZSB5b3UgbG9vayAtIG5vIHBhc3N3b3JkIGhlcmU=
Pragma: no-cache
Cache-Control: no-cache
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:BuildPipeline xmlns:tns="http://www.example.org/Pipeline/"><tns:Subject><tns:fedoraObjectAndDataStreamSubject><tns:pid>demo:6</tns:pid><tns:dsID>OBJ</tns:dsID></tns:fedoraObjectAndDataStreamSubject></tns:Subject><tns:Options><tns:context><tns:item>IngestTestImage</tns:item><tns:item>MIMEType/image/tiff</tns:item><tns:item>SendVarsToEmail</tns:item></tns:context></tns:Options></tns:BuildPipeline></soap:Body></soap:Envelope>HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Encoding: deflate
SOAPServer: SOAP::Lite/Perl/0.715
Content-Type: text/xml;charset=utf-8
Content-Length: 4019
Date: Wed, 14 Aug 2013 16:26:05 GMT
x....[]s........._........y.......V6......*..T...\D>..D...._.z.0..ht7..
.
.
.
[lots more binary data]
.
.
.
g}.......Z..5.Gg..zap..........z#............
Disabling HTTP transport compression on the SOAP server resolves the issue.
OPTIONS [...] 415 (Unsupported Media Type) jquery-2.0.3.js:7845
OPTIONS [...] No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. jquery-2.0.3.js:7845
XMLHttpRequest cannot load [...]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Please help
Hey Guy,
I don't speak good English ^^ Sorry
In the README you write output format for the last version:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myns="urn://service.my.server.com"> <soap:Body> <myns:helloWorld> <name>Remy Blom</name> <msg>Hi!</msg> </myns:helloWorld> </soap:Body> </soap:Envelope>
but really is this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <myns:helloworld xmlns:myns="urn://service.my.server.com"> <myns:name>Remy Blom</myns:name> <myns:msg>Hi!</myns:msg> </myns:helloWorld> </soap:Body> </soap:Envelope>
My web services connect is not recognize parameter with myns:name...
It is 'name' only.
I have change the variable prefix in the jquery.soap.js to: var prefix = "";
I have tested send request with the SOAPUI and it is correct.
Now, I have 2 possibility for the message format: XML and SOAP with different link.
But it's not work.
Firebug console return me this:
status: string 'error' a:object isXMLDoc(a):false a.responseText:string isXMLDoc(a.responseText):false a.responseXML:undefined isXMLDoc(a.responseXML):false c:string isXMLDoc(c):false c.responseText:undefined isXMLDoc(c.responseText):false c.responseXML:undefined isXMLDoc(c.responseXML):false --a-- Object { readyState=0, status=0, statusText="error"} --c-- (an empty string) { typeOf="SOAPResponse", status="error", headers=[1], more...}
In the network analysis, the response server is:
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS Content-Length: 0 Date: Thu, 16 May 2013 11:42:59 GMT
Do you have an idea of what does not work?
Many thanks
Hi,
Its not an issue but a question.
In ajax we have an option to 'async'. While using soap library how can I set that?
Both Tom Simnett and Sergio found an error in the way json2soap handled Arrays. Looking for a fix I presumed that you want json2soap to convert in the presented way. If someone disagrees, let me know!
For instance:
{
val: 0,
object: {
a: 1, b: 2, c:3
},
array: [4,5,6],
objects: [
{a: 7}, {a: 8}
]
}
is converted to:
<helloWorld>
<val>0</val>
<object>
<a>1</a>
<b>2</b>
<c>3</c>
</object>
<array>4</array>
<array>5</array>
<array>6</array>
<objects>
<a>7</a>
</objects>
<objects>
<a>8</a>
</objects>
</helloWorld>
Version 1.3.4 on https://github.com/doedje/jquery.soap has a fix that handles Arrays as above...
would you consider updating this section with more descriptive variable names? Instead of using "a" and "c", consider using "xml" and "object" or more specifically "xhr" so that when they fail, a develop can know that it is the xml and/or xhr object is failing.
'''
xhr.always(function(a, status, c){
var response;
log("status: " + $.type(status) + " '" + status + "'");
log("a:" +
log("c:" +
log("--a--");
log(a);
log("--c--");
log(c);
first of all, thanks for this very useful lib.
I'm using it with angularJS so my soap service returns a promise to controller.
How can i parse response in done status
This is service
.factory('contactService', ['$http', 'CONFIG',
function ($http, CONFIG) {
return {
findContacts: function () {
return $.soap({
url : CONFIG.contact.url,
method : CONFIG.contact.find,
namespaceURL : CONFIG.contact.namespace,
data: {}
});
},
And controller
contactService.findContacts()
.done(function(data, textStatus, jqXHR) {
var response = new SOAPResponse(textStatus, jqXHR);
console.log($.parseXML(response.toString()).firstChild);
});
Error SOAPResponse is undefined
Hi doedje,
It looks like gSoap using SOAP1.2 is very picky on the namespace URL. The trailing slash should be removed from it.
--- jquery.soap.js.orig 2014-02-27 14:49:11.490460762 +0100
+++ jquery.soap.js.new 2014-02-27 14:49:27.070460780 +0100
@@ -374,7 +374,7 @@
},
SOAP12: {
type: 'application/soap+xml',
- namespaceURL: 'http://www.w3.org/2003/05/soap-envelope/'
+ namespaceURL: 'http://www.w3.org/2003/05/soap-envelope'
},
processData: function(options) {
var soapObject;
A web service is waiting for a xml exactly like this one with the <![CDATA[ part
var xml = "<LabelProperties>" +
"<DuplicationAllowed>true</DuplicationAllowed>" +
"<HorizontalAlignment>CENTER</HorizontalAlignment> " +
"<VerticalAlignment>CENTER</VerticalAlignment> " +
"<Priority>5</Priority>" +
"<OverlapAllowed>false</OverlapAllowed>" +
"<LabelExpression>Degrees</LabelExpression>" +
"<LabelFollowingPath>true</LabelFollowingPath>" +
"<ZoomMin linearUnit=\"km\">0</ZoomMin>" +
"<ZoomMax linearUnit=\"km\">100000</ZoomMax>" +
"<HorizontalOffset>0</HorizontalOffset>" +
"<VerticalOffset>0</VerticalOffset>" +
"<Rendition><![CDATA[ " +
"<Style>" +
"<rendition>" +
"<style font-family=\"Arial\" font-size=\"12.0\" " +
"symbol-mode=\"font\" symbol-foreground=\"white\" " +
"symbol-background=\"red\" symbol-background-opacity=\"3\" " +
"symbol-foreground-opacity=\"1\"/>" +
"</rendition>"+
"</Style>"+
"]]></Rendition>"+
"</LabelProperties>";
So im doing like this to pass it:
$.soap({
url: 'https://url.com/version_4.8/services/LayerService',
method: 'setOverrideLabelTheme',
appendMethodToURL: false,
data : {
xmlLabelProperties : xml
},
error: function(){
console.log("Error setOverrideLabelTheme");
},
success: function(soapResponse){
console.log(soapResponse)
}
});
But I have the following error:
SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
Is there a way I could pass this xml through jquery.soap? I cant change the way the server is processing the input...
This can be fixed as follows -
IE8 does not like for-in loops, so simply replace
for (var i in xmldom.attributes) {
with
for (var i = 0; i < xmldom.attributes.length; i++) {
and
for (var j in xmldom.childNodes) {
with
for (var j = 0; j < xmldom.childNodes.length; j++) {
...and all is well.
I invoke a PHP webservice from a HTML page and the expected SOAP response is returning, but there is an error:
status: string 'parsererror'
The versions are:
jquery-1.10.2.min.js
jquery.soap.js 1.2.1
I invoke the webservice with this code:
$.soap({
url: 'http://localhost/webservices.php/',
method: 'suma',
appendMethodToURL: true,
soap12: false,
params: {
a: '3',
b: '4'},
success: function (SOAPresp) {
alert('Ok');
},
error: function (SOAPerror) {
alert(SOAPerror);
},
enableLogging: true
});
The method "suma" just add the two parameters (3+4). I receive "httpCode: 200" and "httpText: 'OK'. However, I don't receive the 'Ok' alert, but the next one (the error function):
Am I using jquery.soap wrongly?
Best regards,
Ignacio Corral
Hey folks,
I've been using jQuery.soap for a while now, but today I ran into an issue.
I built the request by myself using xml and saw that additional headers (like WSS) aren't added, since the toString-functions doesn't gets called.
Could you please have a look ?
Thanks in advance!
Regards
Ray
Hi!
Im a using jquery.soap to call a webservice that is expecting an array of string as data but it seems that the posted xml are just strings, not lists, and this is causing that error on the server side: Found character data inside an array element while deserializing
$.soap({
url: 'https://carto48dev.mels.gouv.qc.ca/pushnsee_4.8/services/MapService',
method: 'addFilteredLayer',
appendMethodToURL: false,
data : {
mapInstanceKey: mapKey,
tablePath: "Projects Files/soap_drill/Municipalite_General.TAB",
layerName: "Drilled Mun",
separators: ["AND"],
fieldNames: ["Code_CS_Franco"],
operators: ["="],
values: [code_cs,]
},
error: function(){
console.log("Error addFilteredLayer");
},
success: function(soapResponse){
console.log(soapResponse)
}
});
Posted XML:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<addFilteredLayer>
<mapInstanceKey>438455402</mapInstanceKey>
<tablePath>Projects Files/soap_drill/Municipalite_General.TAB</tablePath>
<layerName>Drilled Mun</layerName>
<separators>AND</separators>
<fieldNames>Code_CS_Franco</fieldNames>
<operators>=</operators>
<values>854</values>
</addFilteredLayer>
</soap:Body>
</soap:Envelope>
Hi,
I'm trying to create the following SOAP request:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:whm="http://namespace.org/WHM">
<soap:Body>
<test>Test</test>
</soap:Body>
</soap:Envelope>
But I'm ended up with:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<test>Test</test>
</soap:Body>
</soap:Envelope>
Code what I'm using:
var xml = '<test>Test</test>';
$.soap({
url: "https://example.com/ws/Service.asmx",
envAttributes: {
'xmlns:whm': 'http://namespace.org/WHM'
},
data: xml,
success: function(resp) {
console.log("RESPONSE OK");
},
error: function(resp) {
console.log("RESPONSE FAILED");
}
});
I'm using jQuery v1.9.1 and jQuery Soap v1.3.9
Please assist if possible.
Thank you
In the soap response I'd like to use var rtn = SOAPResponse.toJSON() and extract the returned value but don't know how to reference it. My action/method is LMSLaunch. It appears that it's under rtn.soap:Body.LMSLaunchResponse.LMSLaunchResult but I'm unable to reference it that way. What am I doing wrong... again! ;-)
In the SOAP demo, the following SOAP request is generated:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><test>some text here...</test></soap:Body></soap:Envelope>
And in the demo, the params
is literally defined as <test>some text here...</test>
However, I want to do something a little more complicated. This is the SOAP request that I want to automatically generate:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><a1:myMethod xmlns:a1="http://www.mySpecialNamespace.org/"><number>0</number><color xsi:type="a1:pastel">lavender</color><horizon xsi:type="a1:blues"><ocean>aquamarine</ocean><sky>turqoise</sky></horizon></a1:myMethod></soap:Body></soap:Envelope>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
right at the top at the soap:Envelope
level, but to implement it, it looks like I have to hard code that into the jquery.soap.js
file in the SOAPRequest.toString function and add it as an additonal soapEnv.attr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");a1
and the namespaceURL xmlns:a1="http://mySpecialNamespace"
for myMethod.number
which I already can do through the current SOAPTool.json2soap function.xsi:type
attribute that uses my namespace qualifier a1
and another element to describe it pastel
. To do this it looks like I'd need to add a childObject.attr line in SOAPTool.json2soap().xsi:type
attribute to more complex elements like horizon, which has two sub elements ocean
and sky
and those two sub elements can not have the attribute. This subtlety looks particularly difficult to implement.soap:Envelope
.I think I could accomplish this if I made a lot of significant changes to the jquery.soap.js
file, but it'd be much better if you could update the baseline of the code to include this functionality, or show me how I can already do this and call $.soap to accomplish this specific SOAP request, because I want to be able to easily update my code whenever the latest version of the jquery.soap.js
file comes out.
Thank you so much in advance for your help!!
Thanks,
programmer117
Hello,
Is it possible to add a header within the envelope?
Need to make a query like this;
< soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" >
< soapenv:Header >
< wsse:Security >
< wsse:UsernameToken >
< wsse:Username>xxx< /wsse:Username >
< wsse:Password>xxx< /wsse:Password >
</ wsse:UsernameToken >
</ wsse:Security >
</ soapenv:Header >
< soapenv:Body >
< tem:Test >
< tem:Data>{"StockID":1}< /tem:Data >
< /tem:Test >
< /soapenv:Body >
< /soapenv:Envelope >
Hello!
Here's the problem...
The same code works if I run this on the iOS simulator, but on Android I have the following error:
11-17 18:22:27.318: D/CordovaLog(1778): file:///android_asset/www/js/jquery.soap.js: Line 392 : Uncaught Error: Unexpected Content: null
The code is very easy, as I'm only testing some features.
So the code to include js files is the following:
<script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.soap.js"></script> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript"> app.initialize(); </script>
in app.initialize I wait for the "deviceready" event to fire the following jquery soap call:
$.soap({
url: 'http://<soapurl_here>/api/?wsdl',
method: 'login',
data: {
username:'<user_here>',
apiKey:'<api_key_here>'
},
success: function (s) {
alert("success");
},
error: function (e) {
alert("error");
}
});
Any hints?
Thanks in advance!
Hello,
It would be great if the request could be cancelled by returning false from beforeSend. Like $.ajax.
Thanks for reading !
In json2soap, String objects (built with "new String('...')") are processed as normal objects and produce an invalid XML file.
In demo, try "{ test: new String('some text here...') }" in params.
You will get the following error:
Uncaught Error: Invalid XML: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><myns:helloWorld xmlns:myns="urn://service.my.server.com"><myns:test><myns:0>s</myns:0><myns:1>o</myns:1><myns:2>m</myns:2><myns:3>e</myns...
To fix this, I have added a new "if" in json2soap() function, to detect object strings and processed them as a primitive value.
Here is the unified diff of the function:
json2soap: function (name, params, prefix, parentNode) {
var soapObject;
var childObject;
if (params === null) {
soapObject = new SOAPObject(prefix+name);
soapObject.attr('nil', true);
} else if (typeof params == 'object') {
// soapObject = new SOAPObject(prefix+name);
// added by DT - check if object is in fact an Array and treat accordingly
if(params.constructor.toString().indexOf("Array") > -1) { // type is array
// soapObject = parentNode;
for(var x in params) {
childObject = this.json2soap(name, params[x], prefix, parentNode);
parentNode.appendChild(childObject);
}
+ } else if (params.constructor.toString().indexOf("String") > -1) { // type is string
+ // handle String objects as string primitive value
+ soapObject = new SOAPObject(prefix+name);
+ soapObject.val(''+params); // the ''+ is added to fix issues with falsey values.
} else {
soapObject = new SOAPObject(prefix+name);
for(var y in params) {
childObject = this.json2soap(y, params[y], prefix, soapObject);
if (childObject) {
soapObject.appendChild(childObject);
}
}
}
} else {
soapObject = new SOAPObject(prefix+name);
soapObject.val(''+params); // the ''+ is added to fix issues with falsey values.
}
return soapObject;
},
PS: I do not really use new String() to create a string, but I am defining new methods in String.prototype, and when using these added methods my string are converted to Objects.
Hi,
I am using jquery-1.10.2.min.js, jquery.soap.js (v1.3.1).
It works on all major browers but I have a constraint and need to make it work on IE 8 as Windows XP is still common :(
I've read jquery 1.x was compatible with IE 8 and I thought this lib was based on the ajax object so it should be compatible ?
However, when testing it, I have the following error :
"This object doesn't handle this action" line 425, caracter : 4 in jquery.soap.js.
which correspond to :
" for (var i in xmldom.attributes) {"
Any help will be much appreciated ?
One of the soap request I'm running :
$.soap({
url: '/SatcomSupervision',
appendMethodToURL: false,
async: true,
data: "<GetMyRouter xmlns="http://www.satcom1.com/AvioIP\">" +
"0" +
"",
HTTPHeaders: {
'SOAPAction': 'http://www.satcom1.com/AvioIP/GetMyRouter',
'Content-Type': 'text/xml; charset=utf-8'
},
success: function (soapResponse) {
$("#mainContent").fadeTo("slow", 1);
var soapRep =
GetMyRouter_cb(soapRep.documentElement);
},
error: function (soapResponse) {
console.log(soapResponse);
$("#mainContent").fadeTo("slow", 0.5);
}
}).always(function(){
var myTimeout = setTimeout(function(){GetMyRouter();},timer);
});
E.g. the addHeader method is present on SOAPEnvelope but there's no way to create a SOAPObject to add as a header nor is the method to convert the json into SOAPObjects exported.
It would be useful if there was a similar config parameter for soap headers as there is for data currently.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.