Get the soap request skeleton - soap

I am using the soapUI core (classes) to invoke operation for the given WSDL.
I am trying to get the soap request skeleton of a given operation.
Is there any method in WsdlOperation, WsdlRequest that return the skeleton of the soap request. for example:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Header>
</soap:Header>
<soap:Body>
<soap:Fault>
</soap:Fault>
</soap:Body>
Thanks.

Related

Accumulating SOAP responses together with SOAP requests through wso2esb mediation

I have a SOAP web service which can be accessed like:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:sys="system">
<soap:Body>
<sys:getAccountInfo>
<account id="132456"/>
</sys:getAccountInfo>
</soap:Body>
</soap:Envelope>
This web service would provide the following response:
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns1:getAccountInfoResponse xmlns:ns1="system">
<balance value="555">
</ns1:getAccountInfoResponse>
</S:Body>
</S:Envelope>
My challenge is to provide a proxyfying service which can accept multiple accounts as an input and respond with balance for each one like the following:
Request into proxy:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:sys="systemProxy" xmlns:inner="innerProxyNamespace">
<soap:Body>
<sys:getAccountInfo>
<inner:account id="123456"/>
<inner:account id="123457"/>
<inner:account id="123458"/>
</sys:getAccountInfo>
</soap:Body>
</soap:Envelope>
Proxy response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:sys="systemProxy" xmlns:inner="innerProxyNamespace">
<soap:Body>
<sys:getAccountInfoResponse>
<inner:account id="123456">
<inner:balance value="555"/>
</inner:account>
<inner:account id="123457">
<inner:balance value="666"/>
</inner:account>
<inner:account id="123458">
<inner:balance value="777"/>
</inner:account>
</sys:getAccountInfoResponse>
</soap:Body>
<soap:Envelope>
I am using Iterate and Aggregate mediator for splitting incoming request into multiple requests to backend and accumulating responses from backend into single message. The problem is I can not find the right way to include account id into proxy response even with Enrich mediator.
I do iteration sequence like this:
<!-- it is correct proxy incoming message format -->
<iterate attachPath="soap:Body/sys:getAccountInfo"
expression="$body/sys:getAccountInfo/account"
preservePayload="true"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sys="systemProxy">
<target>
<sequence>
<payloadFactory>
<!-- payloadFactory configuration skipped -->
</payloadFactory>
<enrich>
<source clone="true" type="body"/>
<target property="originalRequest" type="property"/>
</enrich>
<send>
<endpoint key="BackendEndpoint"/>
</send>
</sequence>
</target>
</iterate>
So the question is - what is the right way to aggregate all response messages from backend into one preserving data from the original request?
I used Propetry and PayloadFactory mediators before the Aggregate mediator. It let me include request into response before aggregation. Then I aggregated them all together.

EWS request fails because not Internet

I am calling EWS service on internal network which has not access to Internet.
I can open EWS url with browser and verify that it is up an running.
But when I try to send the SOAP request.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
</soap:Header>
<soap:Body>
<m:GetFolder>
<m:FolderShape>
<t:BaseShape>IdOnly</t:BaseShape>
</m:FolderShape>
<m:FolderIds>
<t:DistinguishedFolderId Id="calendar" />
</m:FolderIds>
</m:GetFolder>
</soap:Body>
</soap:Envelope>
It fails with error ENOTFOUD. I am assuming that it can not connect to given address in the SOAP xml for schema definitions.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
How to deal with this when there is no internet connection.
I am sending request from meteor.js app using lather.js library.
The stuff that looks like URL:s, prefixed with xmlns, are just name spaces and shall not be called. A bit like namespaces in a java program (for example namespace com.sun.something) is not an url you can call.
You should just do a http POST and send the entire xml file to the soap server, which can be an internal ip number that is not on the internet.

How to retrieve SOAP response header in a SOAPFaultException in Apache CXF

I have a trouble in Apache CXF where some code throws SOAPFaultException.
My original SOAP response is as following :
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope ...>
<soap:Header>
<awsse:Session TransactionStatusCode="InSeries">
<awsse:SessionId>012GBF5W3H</awsse:SessionId>
<awsse:SequenceNumber>1</awsse:SequenceNumber>
<awsse:SecurityToken>3CGFFDO499VDB7WTRT37R6HPV</awsse:SecurityToken>
</awsse:Session>
</soap:Header>
<soap:Body>
<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soap:Client</faultcode>
<faultstring>SOME_FAULT_STRING</faultstring>
<faultactor>SOME_FAULT_FACTOR</faultactor>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I receive later a SOAPFaultException with information contains only soap:Body/soap:Fault. However, I need information from soap:Header section for further processing.
How can I pass these Header information to SOAPFaultException?

Request to web services failed using php, succeeded from windows client

I have written a web service using asp.net 2.0 and a simple method "HelloWorld" to test it. Here is the soap envelope which the server receives:
<?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:Header>
<SoapAuthHeader xmlns="http://myservice.anywhere.net/">
<UserName>MyUser</UserName>
<Password>MyPassword</Password>
</SoapAuthHeader>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://myservice.anywhere.net/">
<request>
<?xml version="1.0" encoding="utf-16"?>
<HelloWorld />
</request>
</HelloWorld>
</soap:Body>
</soap:Envelope>
My Problem is: If I send the request from a Windows Client with embedded wsdl it succeeds. If I send the request from php (or SoapUI) the request fails - the server gets no "request" string, means no content for the body.
The server receives in both cases the same soap envelope above (logged it with a trace extension).
Thanks for any help.
Harald
P.S. No matter if I use embedded XML or embedded string for the request.
Using the asmx trace I have found the problem at least with SoapUI. The requested requirement category was "text/xml" and it got "application/soap+xml". I have disabled "Soap action" and the call succeeds.

sudzc generates wrong soap request

I tried to use Sudzc to generate my SOAP requests. But the generated requests are wrong.
Below are the Sudzc generated soap request and the working SoapUI request of a very simple example request. Has anybody experienced the same problems?
Sudzc generated soap request:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:sap-com:document:sap:soap:functions:mc-style">
<soap:Body>
<urn:ZcaptoSccMatDet>
<IvMatnr>D300</IvMatnr>
</urn:ZcaptoSccMatDet>
</soap:Body>
</soap:Envelope>
Working SoapUI generated message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap com:document:sap:soap:functions:mc-style">
<soapenv:Header/>
<soapenv:Body>
<urn:ZcaptoSccMatDet>
<IvMatnr>D300</IvMatnr>
</urn:ZcaptoSccMatDet>
</soapenv:Body>
</soapenv:Envelope>
Kay,
If you need to change the output to soapenv take a look at the (Sudzc generated) code in Soap.m. In particular, check out the createEnvelope method. You can update the hardcoded references in this method from soap to soapenv.