I want to consume a simple SOAP web service using REST technology. I've heard it can be achieved using POST method. Just adding some headers to the request. Is it possible? How to do that? Thanks a lot !!!
SOAP considers different information in the headers/body than REST does, but it's all HTTP:
# Headers
Content-Type: text/xml
SOAPAction: <SOAPAction here>
# Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header>
.
</soapenv:Header>
<soapenv:Body>
.
.
.
</soapenv:Body>
</soapenv:Envelope>
You'll need to fill in the actual body with whatever the SOAP service expects (obviously) - that can be found in the WSDL if you don't have any sample requests available.
I found this blog post to be very helpful, even if you're making the call from some non-postman tool.
Related
I am trying to use the Tsoap component within Talend to consume the API. I have tried the Soap UI Client (separate application) and was able to get the response.
However within the Tsoap component within the Soap Message, I have pasted the sample request and I get an error eery single time. Can anyone help!
" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns=\"http://clients.mindbodyonline.com/api/0_5\">
<soapenv:Header/>
<soapenv:Body>
<GetSites>
<Request>
<SourceCredentials>
<SourceName>Test235</SourceName>
<Password>3IERKOFDNFEOFMKDFOEMFD=</Password>
<SiteIDs>
<int>-99</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Full</XMLDetail>
<PageSize>0</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
</Request>
</GetSites>
</soapenv:Body>
</soapenv:Envelope>"
What am I doing wrong?? Can anyone help please.
Can you send the error what you are getting?
Try this if you haven't done (just a guess)
--> If you are using and HTTPS web service then make sure to setup the authentication( I used Trust serve with SLL and provided the keystore file path and password)
I want to call a Web Service using Apache Camel and I have the SOAP message in the form of String. Can anyone kindly let me know how to send SOAP request in form of String in Camel?
Here is a simple example. If you need to perform some modifications of SOAP request string you can just change "constant" to something like "spel"
<setBody><constant><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<MyAction>
<myparam>ABC</myparam>
</MyAction>
</soapenv:Body>
</soapenv:Envelope>]]></constant></setBody>
<setHeader headerName="SOAPAction"><constant>MySOAPAction</constant></setHeader>
<setHeader headerName="CamelHttpMethod"><constant>POST</constant></setHeader>
<setHeader headerName="Content-Type"><constant>text/xml;charset=UTF-8</constant></setHeader>
<to uri="http://myserver:1234" />
It depends of what type of endpoint you have for your outbound webservice.
If it is a CXF JAX-WS then it depends on what dataFormat property is set to: POJO or PAYLOAD.
For POJO you have take SOAP headers, SOAP Body elements, unmarshal them to JAXB Pojos, then set them to Camel Exchange Body properly pass Exchange to endpoint
For PAYLOAD - I'm not sure but maybe you can pass your string as is (or just SOAP body and SOAP headers elements) as strings. If not, check what CXF expects to get when dataFormat is PAYLOAD. (I just used it long time back).
For simple http endpoint just pass your string to it "as is" in the body with Http-method POST and Content-type header as application/xml
From doing some testing on SOAP requests to a webservice I created in Salesforce I note the response returned is of the following format.
Note my request function I called is GetMsgRQ
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/MyIntegrationServices">
<soapenv:Body>
<GetMsgRQResponse>
<result>
<acctId>001J000000leVpEIAU</acctId>
<acctName>MyTest</acctName>
</result>
</lGetMsgRQResponse>
</soapenv:Body>
</soapenv:Envelope>
Relating to this I wonder is it possible to add a SOAP:Header?
Also I note the response has created an element "GetMsgRQResponse" (adding "Response" to "GetMsgRQ". Is it possible to create/specify the SOAP:Body without this occuring? Can I just set what the whole SOAP body response will be or will Salesforce always add such additional elements as the "GetMsgRQResponse" here and "result"?
Thanks in advance for any help on this. I know I can use a HTTP Request to send a full SOAP envelope but for my requirement I need to just provide a response instead of doing so.
I don't believe you can directly add any kind SOAP headers in an Apex defined WebService methods.
If you have absolutely no other option you could construct your own custom SOAP response via a REST web service (via #RestResource annotation) but that is a pretty ugly solution.
I have a SOAP request of this form:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:myqname="http://example.com/hello"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<myqname:MyRequest xmlns:myqname="http://example.com/hello">
...
</myqname:MyRequest>
</soapenv:Body>
</soapenv:Envelope>
If I ask SOAPUI to "Format XML" this request,
it removes the second declaration of myqname, so I get this:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:myqname="http://example.com/hello"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<myqname:MyRequest>
...
</myqname:MyRequest>
</soapenv:Body>
</soapenv:Envelope>
The original request works fine,
but the Application Servers fails with the modified request with this error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'myqname:MyRequest' as a QName: the prefix 'myqname' is not declared.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
According to the web services specification,
is it mandatory for the qname to be re-declared inside the soapenv:Body node?
Is this a SOAPUI bug, or an Application Server bug? or a misunderstanding from my part?
SOAPUI 4.0.1, WebLogic Server Version: 10.3.2.0
Edit: ups, even if using WebLogic application server, I was using the CXF web services framework. I posted the issue there. issues.apache.org/jira/browse/CXF-4026
So: SOAPUI 4.0.1, CXF 2.5.0
I'd describe it as a bug in the code that strips the SOAP envelope; it should preserve the namespace context yet it isn't doing so, and that's breaking the XML. I guess that's because it is doing the stripping by taking a substring rather than operating at the DOM element level (whether or not it's using DOM processing to do the stripping is beside the point). I'm not sure which component is doing that stripping because of the way these things can be nested, but I suspect it's WebLogic…
[EDIT]: I've checked the SOAP specification and it does not say that the contents of the body has to directly declare the namespace used (see §5.3.1), though it does say that it SHOULD be namespaced. Because of that, normal XML namespacing rules apply — the whole SOAP message is simply an XML document — and that would make WebLogic's behavior a bug.
I have a problem with the Web Service I recently developed.
The problem is about the Web Service response. More precisely sometimes the Web Service sends back the following response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:GetConstants2Response soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://usermanagerwstest">
<GetConstants2Return xsi:type="ns2:CFComponentSkeleton" xmlns:ns2="http://rpc.xml.coldfusion"/>
</ns1:GetConstants2Response>
</soapenv:Body>
</soapenv:Envelope>
Instead the correct response (that sometimes shows up in an intermittent way) is reported below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:GetConstants2Response soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://usermanagerwstest">
<GetConstants2Return xsi:type="ns1:Constants2">
<BooleanTypeFalse xsi:type="xsd:string">0</BooleanTypeFalse>
<BooleanTypeTrue xsi:type="xsd:string">1</BooleanTypeTrue>
<GenderFemale xsi:type="xsd:string">F</GenderFemale>
<GenderMale xsi:type="xsd:string">M</GenderMale>
<LanguageEnglish xsi:type="xsd:string">inglese</LanguageEnglish>
<LanguageItalian xsi:type="xsd:string">italiano</LanguageItalian>
</GetConstants2Return>
</ns1:GetConstants2Response>
</soapenv:Body>
</soapenv:Envelope>
Where does the CFCComponentSkeleton comes from?
I thank everybody in advance.
It sounds like perhaps the method was missing. When you hit a CFC and don't pass a method, you get the descriptor - a HTML view of the CFC methods. When you do that with ?wsdl in the URL, it should send the WSDL back. But maybe something is getting in the way. Maybe check your web server logs and see if something odd was passed in the URL. Also look into adding some logging within the CFC as well.