how to create xslt which transforms the response message to a soap fault message.please refer the Attached the Input and what i expected Output,xslt Result after xslt transformation.
This is my xml
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<soapenv:Fault>
<soapenv:Code>
<soapenv:Value>soapenv:Sender</soapenv:Value>
</soapenv:Code>
<soapenv:Reason>
<soapenv:Text xml:lang="en">User NotFound</soapenv:Text>
</soapenv:Reason>
<soapenv:Detail>
<axis2ns4:sdpFault xmlns:axis2ns4="http://testservice.com/uat/testservice">
<axis2ns4:resultNameCode>2</axis2ns4:resultNameCode>
<axis2ns4:resultNameType>GH</axis2ns4:resultNameType>
</axis2ns4:sdpFault>
</soapenv:Detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Expecte result
set this message <soapenv:Text xml:lang="en">User NotFound</soapenv:Text>
<ns1:UserDescription>User NotFound</ns1:UserDescription>
Related
I want to host a web-service which will return a response of
<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>
<QcB2BQNBPaymentIntegrationBalUpdatePaymentPostingResponse xmlns="http://tempuri.org">
<response xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>QCP-0031312;158155421123</b:string>
</response>
</QcB2BQNBPaymentIntegrationBalUpdatePaymentPostingResponse>
</soapenv:Body>
</soapenv:Envelope>
but I am getting the response as
<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>
<QcB2BQNBPaymentIntegrationBalUpdatePaymentPostingResponse xmlns="http://tempuri.org">
<response >
<ns1:string xmlns:ns1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">QCP-0031312;158155421123</ns1:string>
</response>
</QcB2BQNBPaymentIntegrationBalUpdatePaymentPostingResponse>
</soapenv:Body>
</soapenv:Envelope>
I want to get the former response. please share some insight.
note: I've generated the java bean skeleton using axis
I need to execute a SOAP request to an external server. I have never worked with SOAP before, but I know the basics of REST.
I've been given this following WSDL file and this example query:
<Messages>
<Version Ds_Version="0.0">
<Message>
<Detail>
<Ds_MerchantCode>999008881</Ds_MerchantCode>
<Ds_Terminal>1</Ds_Terminal>
<Ds_Order>5799L</Ds_Order>
<Ds_TransactionType>3</Ds_TransactionType>
</Detail>
</Message>
</Version>
<Signature>UfECD0KD9Wwo1iqY6PYZoJxw8KwMUz8m18bgLyH3BCI=</Signature>
<SignatureVersion>HMAC_SHA256_V1</SignatureVersion>
</Messages>
I'm using Postman in order to test the API. Following some instructions I found on the internet, I added a Content-Type HTTP header with value text/xml and the SOAPAction HTTP header with value consultaOperaciones as found in the WSDL file.
I've set this body:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body xmlns:m="http://webservices.apl02.redsys.es">
<m:consultaOperacionesRequest>
<Messages>
<Version Ds_Version="0.0">
<Message>
<Transaction>
<Ds_MerchantCode>999008881</Ds_MerchantCode>
<Ds_Terminal>1</Ds_Terminal>
<Ds_Order>5799L</Ds_Order>
<Ds_TransactionType>3</Ds_TransactionType>
</Transaction>
</Message>
</Version>
<Signature>1KoxTgTakbTprzJ2N/e9JJ8yw/C3QzeNafbUMCNGSFM=</Signature>
<SignatureVersion>HMAC_SHA256_V1</SignatureVersion>
</Messages>
</m:consultaOperacionesRequest>
</soap:Body>
</soap:Envelope>
However, when I send the request I receive the following error message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<soapenv:Fault>
<faultcode>Server</faultcode>
<faultstring>Internal Error</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
It's a generic SOAP error message, therefore I think that the problem has to be related to the codification instead of the external service.
Thanks in advance.
In the WSDL file you will see that the XML should be sent as a string:
<element name="consultaOperaciones">
<complexType>
<sequence>
<element name="cadenaXML" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
Hence the XML sent should be:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.apl02.redsys.es">
<soapenv:Header/>
<soapenv:Body>
<web:consultaOperaciones>
<cadenaXML><![CDATA[
<Messages>
<Version Ds_Version="0.0">
<Message>
<Detail>
<Ds_MerchantCode>999008881</Ds_MerchantCode>
<Ds_Terminal>1</Ds_Terminal>
<Ds_Order>5799L</Ds_Order>
<Ds_TransactionType>3</Ds_TransactionType>
</Detail>
</Message>
</Version>
<Signature>UfECD0KD9Wwo1iqY6PYZoJxw8KwMUz8m18bgLyH3BCI=</Signature>
<SignatureVersion>HMAC_SHA256_V1</SignatureVersion>
</Messages>
]]>
</cadenaXML>
</web:consultaOperaciones>
</soapenv:Body>
</soapenv:Envelope>
Note that we are using CDATA because as mentioned the XML message should be sent as a string based on the WSDL. I have tried running it and got the response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p259:consultaOperacionesResponse xmlns:p259="http://webservices.apl02.redsys.es">
<consultaOperacionesReturn><![CDATA[<Messages><Version Ds_Version="0.0"><Message><ErrorMsg><Ds_ErrorCode>XML0023</Ds_ErrorCode></ErrorMsg></Message></Version></Messages>]]></consultaOperacionesReturn>
</p259:consultaOperacionesResponse>
</soapenv:Body>
</soapenv:Envelope>
This means that your message is being parsed now because there are no server errors and a consultaOperacionesResponse is being sent which looks legit. The error seems to be related to the data being sent but in general the API is working fine as expected.
I have an incoming SOAP message as given below. This incoming SOAP message contains an embedded XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the <ns1:disXML> element:
<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:process xmlns:ns1="http://example.com">
<ns1:disXML><?xml version="1.0" encoding="UTF-8"?>
<TP memberFirstName="Tom"></TP>
</ns1:disXML>
</ns1:process>
</soapenv:Body>
</soapenv:Envelope>
How can I remove that embedded declaration?
I am new to webservices ,
wsdl link : http://pp.hotels.travelrepublic.co.uk/ChannelManager.svc?wsdl
I have a wsdl url, easily in netbeans i have created and used.
Input via netbeans to webservice :
I am Sending the Request via java Program in netbeans request is:
<Request><Authentication CMId='68' Guid='5594FB83-F4D4-431F-B3C5-EA6D7A8BA795' Password='poihg321TR' Function='1' /><Establishment Id='4297867' > </Establishment></Request>
the response is :
<Response>
<Authentication CMId="68" Guid="5594FB83-F4D4-431F-B3C5-EA6D7A8BA795" Password="poihg321TR" Function="1" />
<Establishment Id="4297867">
<RoomTypes>
<RoomType RoomTypeId="1040459" Description="Double Room" />
<RoomType RoomTypeId="1040458" Description="Single Room" />
</RoomTypes>
<BoardTypes>
<BoardType BoardTypeId="1" Description="Room Only" />
</BoardTypes>
with the help of SoapUI
request generated is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:RequestData>
<!--Optional:-->
<tem:requestDocument xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</tem:RequestData>
</soapenv:Body>
</soapenv:Envelope>
What i am sending through SoapUI is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:RequestData>
<!--Optional:-->
<tem:requestDocument xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<!--The data sent via java program:-->
<Request>
<Authentication CMId='68' Guid='5594FB83-F4D4-431F-B3C5-EA6D7A8BA795' Password='poihg321TR' Function='1' />
<Establishment Id='4297867' >
</Establishment>
</Request>
<!--The data sent via java program:-->
</tem:RequestData>
</soapenv:Body>
</soapenv:Envelope>
If I run this in SoapUI
Output is not same as
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestDataResponse xmlns="http://tempuri.org/">
<RequestDataResult><Response Error="Unable to parse xml">
<RequestDate Date="2014-05-30 16:14:15.7383" />
</Response></RequestDataResult>
</RequestDataResponse>
</s:Body>
</s:Envelope>
Try:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:RequestData>
<!--Optional:-->
<tem:requestDocument>
<![CDATA[<Request>
<Authentication CMId="68" Guid="5594FB83-F4D4-431F-B3C5-EA6D7A8BA795" Password="poihg321TR" Function="1"/>
<Establishment Id="4297867"></Establishment>
</Request>]]>
</tem:requestDocument>
</tem:RequestData>
</soapenv:Body>
</soapenv:Envelope>
Essentially, the WSDL does not have any of the Request and Authentication and other stuff defined, so you cannot send that. Further, the response tells you: "Unable to parse xml", so the application (as opposed to the service) is looking for XML data.
I created a webservice producer from wsdl file using cxf.response is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://esb.tiaa.org/life-insurance-correspondence-v1/types" xmlns:ns3="http://esb.tiaa.org/indianarmyshortservice">
<soap:Body>
<ns2:getSourcesResponse xmlns:ns2="http://channelmapwebservice.service.web.ccad/">
<return>
<sourceId>3</sourceId>
<sourceName>DUMMY9</sourceName>
</return>
The expected result is
<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:getSourcesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://com.ccadllc.dac.web.service.channelmapwebservice">
<getSourcesReturn soapenc:arrayType="xsd:anyType[644]"
xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<getSourcesReturn xsi:type="ns2:SourceInfo" xmlns:ns2="http://channelmapwebservice.service.web.ccad">
<sourceId xsi:type="xsd:int">3</sourceId>
<sourceName xsi:type="xsd:string">DUMMY9</sourceName>
</getSourcesReturn>
How to obtain the exptected result