What does Envelope refer to in this soap request?
OST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice>
<m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body>
</soap:Envelope>
Related
I have defined an API Resource in WSO2 ESB like this with GET method:
/sms/{username}/{password}/{src}/{destination}/{body}
Now if I invoke my API through a standard browser like chrome or firefox it works fine and I get response code ok 200
127.x.x.x:8280/sms/username/password/123123123/456456456/سلام
But I can not invoke this API through Postman and it returns Not-Found 404. If I replace 'سلام' with a standard ascii string like 'hello' it works fine and it returns code ok 200:
127.x.x.x:8280/sms/username/password/123123123/456456456/hello
I tried numerous Content-Types in Headers tab of postman including this but it didn't work:
text/html; charset=UTF-8
I also monitored network requests with fiddler. Standard browser send request with this parameters:
Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/70.0.3538.77 Safari/537.36 Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9
And Postman send request with this parameters:
Content-Type: text/html; charset=UTF-8 cache-control: no-cache
Postman-Token: 5ccc574f-54d2-4c5b-ac72-b0f5f5a8e0be User-Agent:
PostmanRuntime/7.3.0 Accept: /
accept-encoding: gzip, deflate Connection: keep-alive
I use postman v6.4.4
You need to manually encode parts of the URL.
Try this https://stackoverflow.com/a/49964318/9624430
I tried this issue with WSO2 ESB 5.0.0. It works for me as you expected through postman.
<api xmlns="http://ws.apache.org/ns/synapse" name="test-api" context="/test">
<resource methods="GET" uri-template="/value/{val1}">
<inSequence>
<log level="full">
<property name="test" expression="get-property('uri.var.val1')"/>
</log>
<payloadFactory media-type="json">
<format>{ "test": "$1"}</format>
<args>
<arg evaluator="xml" expression="get-property('uri.var.val1')"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
Request: http://localhost:8280/test/value/سلام
Response:
{
"test": "سلام"
}
Try with WSO2 ESB 5.0.0.
I'm attempting to run a search for a ticket on ChangeGear 5.0. Their API utilizes SOAP requests, and when I run a request to search I get the error "Object reference not set to an instance of an object". I've looked through existing topics concerning the same issue (there are a lot of them), and I've tried all of them with no luck. Non-required parameters are included as empty tags instead of omitted entirely, I've tried capitalizing the names of the parameters, and I've made sure the request is formatted appropriately according to the WSDL.
The provided ChangeGear 5.0 documentation specifies to structure requests like so:
POST /cgweb/cgwebservices/cgwebservices.asmx HTTP/1.1
Host: ...
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Search xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<sessionId>string</sessionId>
<entityType>string</entityType>
<criteria>string</criteria>
<retrieveRelated>boolean</retrieveRelated>
<entityTemplate>string</entityTemplate>
</Search>
</soap12:Body>
</soap12:Envelope>
This is the request I'm POSTing with the specified headers:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Search xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<sessionId></sessionId>
<entityType></entityType>
<criteria></criteria>
<retrieveRelated>true</retrieveRelated>
<entityTemplate></entityTemplate>
</Search>
</soap12:Body>
</soap12:Envelope>
The only parameter I've set is retrieveRelated because as specified by the WSDL it is the only required parameter, but I've also tried setting all the string parameters to arbitrary non-null values and received the same result. I'm sure the API is functional because when I use the login operation it returns successfully:
POST /cgweb/cgwebservices/cgwebservices.asmx HTTP/1.1
Host: ...
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Login xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<userName>...</userName>
<password>...</password>
</Login>
</soap12:Body>
</soap12:Envelope>
Result:
200 OK
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<LoginResult>...</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
I am using the same session I used for the login operation. Is there anything else I can try besides including empty tags for omitted parameters or capitalizing their names? The full error is:
500 Internal Server Error
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Object reference not set to an instance of an object.</soap:Text>
</soap:Reason>
<soap:Node>.../cgweb/cgwebservices/cgwebservices.asmx</soap:Node>
<detail>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage/>
<ErrorCode>L_REJECT_CHANGES_FAILED</ErrorCode>
</Error>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage>Object reference not set to an instance of an object.</ErrorMessage>
<ErrorCode>Object reference not set to an instance of an object.</ErrorCode>
</Error>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage>Object reference not set to an instance of an object.</ErrorMessage>
<ErrorCode/>
</Error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The problem was that the server wasn't adhering to the WSDL. The entityTemplate parameter was required, and without it the server returns the "Object reference not set to an instance of an object" error. When I initially tested the parameters with dummy values, out of coincidence I had accidentally forgot to set this one -- the only one that strayed from the WSDL specification.
I have this SOAP response:
<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>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>0.1492</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
and I want to get the value:
0.1492
How do I state this using xpath?
My SoapUI response as 'raw' is:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 31 Oct 2014 19:43:54 GMT
Content-Length: 316
<?xml version="1.0" encoding="utf-8"?><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><ConversionRateResponse xmlns="http://www.webserviceX.NET/"><ConversionRateResult>0.1482</ConversionRateResult></ConversionRateResponse></soap:Body></soap:Envelope>
In pure XPath, trivially:
//ConversionRateResult/text()
But since XPath is usually embedded into a higher-level language like Java or XSLT, you might as well need (an XSLT example):
<xsl:template match="ConversionRateResult">
<xsl:value-of select="."/>
</xsl:template>
it will be greatful if you help me with this issue, i am a beginner on this platform and this is the first time am using SOAP service. , and i need to implement a login page. i don't know how to use the datas from the service.
POST /soap.asmx HTTP/1.1
Host: www.bids4all.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.bids4all.com/Login"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.bids4all.com" xmlns:types="http://www.bids4all.com/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:Login>
<Email xsi:type="xsd:string">string</Email>
<Password xsi:type="xsd:string">string</Password>
</tns:Login>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.bids4all.com" xmlns:types="http://www.bids4all.com/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:LoginResponse>
<LoginResult xsi:type="xsd:boolean">boolean</LoginResult>
</tns:LoginResponse>
</soap:Body>
</soap:Envelope>
will you please help me with some cods? thank you in advance
There are 2 good tools to generate SOAP client for iOS. They are SudzC and wsdl2objc project. Both of them supply example codes.
You can either use one of them or generate your own request and post it by NSURLConnection.
Hope it helps...
I am using Coldfusion9 to interact with a 3rd party SOAP service with which I need to both send and receive SOAP with attachments. I am having no issue in receiving the SOAP which may or may not have binary attachments by using ToString() around the HTTP content to convert the SOAP Body into a usable string, however the service requires that I send my response back using attachments as well which is where I am coming undone. I've just never done this in ColdFusion and i'm not exactly sure how I should be presenting this to the originating service so that the SOAP body is referenced via an ID.
Below is the parsing of the incoming SOAP data with attachments:
<cfset soapData = GetHttpRequestData()>
<!--- Loop over the HTTP headers and dump the SOAP content into a variable --->
<cfsavecontent variable="soapContent">
<cfoutput>
<cfloop collection = #soapData.headers# item = "http_item">
#http_item#: #StructFind(soapData.headers, http_item)# #chr(10)##chr(13)#
</cfloop>
request_method: #soapData.method# #chr(10)##chr(13)#
server_protocol: #soapData.protocol# #chr(10)##chr(13)#
http_content --- #chr(10)##chr(13)#
#toString(soapData.content)#
</cfoutput>
</cfsavecontent>
<!--- Save file to flat file --->
<cffile action = "write"
file = "#expandPath('../')#logs/#dateFormat(now(),'dd-mm-yyyy')#_#timeFormat(now(),'HHmmss')#.txt"
output = "#soapContent#">
Now I am currently presenting the response as a full SOAP XML response containing the body as inline XML with the required STATUSCODE (see below).
<cfsavecontent variable="strResponse">
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<SOAPENV:Body>
<ns1:processResponse xmlns:ns1="urn:TripFlow" SOAPENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<STATUSLVL>00</STATUSLVL>
</ns1:processResponse>
</SOAP-ENV:Body>
</SOAPENV:Envelope>
</cfsavecontent>
<!--- Strip all whitespace between tags --->
<cfset strResponse = trim(ReReplaceNoCase(strResponse,'(>[\s]*<)','><','ALL'))>
<!--- Output the XML response to the soap service --->
<cfoutput>#strResponse#</cfoutput>
The above response is throwing an error because the SOAP service requires the response to be sent referencing the body message as an attachment exactly like follows from the documentation:
HTTP/1.1 200 OK
Date: Thu, 01 Apr 2010 09:30:25 GMT
Server: Jetty/5.1.4 (Windows XP/5.1 x86 java/1.5.0_15
Content-Type: multipart/related; boundary=soaptestserver; type="text/xml"; start="<theenvelope>"
SOAPAction: ""
Content-Length: 796
Connection: close
--soaptestserver
Content-ID: <theenvelope>
Content-Transfer-Encoding: 8bit
Content-Type: text/xml; charset=utf-8
Content-Length: 442
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAPENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><SOAPENV:
Body><ns1:processResponse xmlns:ns1="urn:TripFlow" SOAPENV:
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><message
href="cid:thecontentmessage"/></ns1:processResponse></SOAP-ENV:Body></SOAPENV:
Envelope>
--soaptestserver
SOAP Interface
www.travelsolutions.com 123
travel solutions online V14.0 External System Integration
Content-ID: <thecontentmessage>
Content-Transfer-Encoding: 8bit
Content-Type: text/xml; charset=utf-8
Content-Length: 65
<?xml version="1.0" encoding="UTF-8"?><STATUSLVL>00</STATUSLVL>
--soaptestserver--
Any help would be greatly appreciate as i'm really hitting my head up against a wall on this one. Thanks!
It has been a while since I worked with ColdFusion. The last I remember, it did not provide a harness to send a SOAP attachment. I solved this issue by writing a custom CFX tag with Java that did it for me. The entire SOAP call will need to go through the tag.
The Java library you want to look at if you choose to do this is javax-ws. You also need to find out if the service call has to use MTOM.
Sorry that is not a direct solution, but it is what I had to do with CF a few versions back.
Whenever I interact with SOAP services I usually end up using something similar to this. It generally works. Notice that I have some place-holder text in there that you would need to replace with the appropriate values for your 3rd party provider.
<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<ns1:processResponse xmlns:ns1="urn:TripFlow" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<statuslvl>00</statuslvl>
</ns1:processResponse>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
<!--- Invoke web service to send message--->
<cfhttp url="http://3rd-party-url-here" method="post" timeout="10">
<cfhttpparam type="header" name="content-type" value="text/xml" />
<cfhttpparam type="header" name="SOAPAction" value="""3rd-party-method-name-here""" />
<!---<cfhttpparam type="header" name="accept-encoding" value="no-compression" /> sometimes this is needed --->
<cfhttpparam type="header" name="content-length" value="#len(soap)#" />
<cfhttpparam type="header" name="charset" value="utf-8" />
<cfhttpparam type="xml" name="message" value="#trim(soap)#" />
</cfhttp>