Web service provider has provided us(Client) a wsdl to use their service and consume data. Our requirement is, we just need specific node value called "CHASE", see below test data. We don't want to get all records of info and corresponding nodes in the response.
Here is an example that we have tested in SOAPUI tool. Please suggest and help us how can we frame the web service request technically from the URL provided(http://host:port/ValueMappingInService/ValueMappingInImplBean)? Is it at all possible to drill down the request and get specific response from client side?
Web service Request:-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bas="http://sap.com/xi/BASIS">
<soapenv:Header/>
<soapenv:Body>
<bas:ValueMappingReadRequest>
<!--Optional:-->
<ReadContext>User</ReadContext>
<!--Zero or more repetitions:-->
<ValueMappingID>c44f541f-c8ac-11e8-86e5-0050569d98cc</ValueMappingID>
</bas:ValueMappingReadRequest>
</soapenv:Body>
</soapenv:Envelope>
Web service Response:-
<SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns2:ValueMappingReadResponse xmlns:ns2="http://sap.com/xi/BASIS">
<ValueMapping>
<MasterLanguage>EN</MasterLanguage>
<AdministrativeData>
<ResponsibleUserAccountID>gdonna</ResponsibleUserAccountID>
<LastChangeUserAccountID>gdonna</LastChangeUserAccountID>
<LastChangeDateTime>2018-10-05T09:47:38.237-05:00</LastChangeDateTime>
<FolderPathID>/</FolderPathID>
</AdministrativeData>
<ValueMappingID>c44f541f-c8ac-11e8-86e5-0050569d98cc</ValueMappingID>
<GroupName>Mercedes</GroupName>
<Representation schemeAgencyID="LOC_BANK" schemeID="BANK">CHASE</Representation>
<Representation schemeAgencyID="LOC_SITE" schemeID="DIR">comm/as2/chase/receive/</Representation>
<Representation schemeAgencyID="LOC_COUNTRY" schemeID="CODE">US</Representation>
</ValueMapping>
<LogMessageCollection/>
</ns2:ValueMappingReadResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Try using a Groovy Script. I really like the features of the XMLSlurper, which lets me ignore the namespaces if/when they change.
Just add a new Groovy Script teststep, and put this into it. You just need to adjust the name of your Soap Request teststep, which should be placed just before this teststep.
/** The name should be modified to match the request/response you want to validate */
def holder = new com.eviware.soapui.support.GroovyUtils( context ).getXmlHolder("The Name Of Your Soap Request TestStep#Response")
def response = new XmlSlurper().parseText(holder.getXml())
for (def element : response.Body.ValueMappingReadResponse.ValueMapping.Representation)
{
log.info element
log.info element.#'schemeAgencyID'
}
Related
I need two responses from soap web service where I should get the first response and after some time based on the element (ResponseCode in my case) in the first response, the second response should come. Below are the sample 2 responses I need form the soap web service
Response1:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://cp.abc.com/cpinterface/request">
<soapenv:Header/>
<soapenv:Body>
<req:ResponseMsg><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Response>
<ResponseCode>0</ResponseCode>
<ResponseDesc>The service request is processed successfully.</ResponseDesc>
<ServiceStatus>0</ServiceStatus>
</Response>]]></req:ResponseMsg>
</soapenv:Body>
</soapenv:Envelope>
Response2:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<res:ResultMsg xmlns:res="http://cp.abc.com/cpinterface/result"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Result>
<ResultType>0</ResultType>
<ResultCode>0</ResultCode>
<ResultDesc>Process service request successfully.</ResultDesc>
<ResultParameters>
<ResultParameter>
<Key>EndDate</Key>
<Value>20140103</Value>
</ResultParameter>
<ResultParameter>
<Key>EndTime</Key>
<Value>210156</Value>
</ResultParameter>
<ResultParameter>
<Key>Fee</Key>
<Value>0.89</Value>
</ResultParameter>
</ResultParameters>
</Result>]]></req:ResultMsg>
</soapenv:Body>
</soapenv:Envelope>
I don't think that's possible, HTTP(S) is one-on-one in the sense that there's one response to one request. There is potentially a loophole you may be able to exploit by using the HTTP status code 100 (continue). Status code 100 means; 'Sofar everything is fine, but more information is coming'. Your client should then continue to wait for the final SOAP response; which then has status code 200 (OK) or 500 (Error). Although in theory it is possible to use a different application protocol (e.g. JMS, SMTP or FTP) to transport SOAP messages, in practice it is usually HTTP(S).
Having said this, I think you shouldn't go down the statuscode 100 route but instead rethink your approach, stick with the 'one response for one request'. The above would be very hacky and tricky to implement.
I'm using a endpoint SOAP created On Spring Framework using JAXB, but I want that my anwers(Expected Response) return without prefix when I Send Request One, but this is returned like is showed on Current Response:.
How can I do to return a message SOAP without namespaces?
Request One
<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:ZProveerDatosPagoProveed2>
<Bukrs>RG10</Bukrs>
<Langu>S</Langu>
<Lifnr>00000000</Lifnr>
</urn:ZProveerDatosPagoProveed2>
</soapenv:Body>
</soapenv:Envelope>
Current Response:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<n0:ZProveerDatosPagoProveed2Response xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">
<Adrnr>0000</Adrnr>
<Bankk>0000</Bankk>
<Bankn>0000</Bankn>
<Bkont>0000</Bkont>
<Iban>ES0000</Iban>
<KoinhFi>ROBLES AVN</KoinhFi>
<Land1>TH</Land1>
<Landx>XXXXX</Landx>
<Name1>ROBLES AVN</Name1>
<Pstlz>0000</Pstlz>
<Stcd1>A0000</Stcd1>
<Stras>ROBLES AVN</Stras>
<Swift>XXXXX</Swift>
<Text1_052>ROBLES AVN</Text1_052>
<Zterm>Z000</Zterm>
</n0:ZProveerDatosPagoProveed2Response>
</soap-env:Body>
</soap-env:Envelope>
Request one and the current response, are the request/response of a web service embedded in another web service (which I implemented), the reason for this implementation is that it has requested that the final answer is this (without namespaces tags):
Expected Response
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<ZProveerDatosPagoProveed2Response xmlns="urn:sap-com:document:sap:soap:functions:mc-style">
<Adrnr>0000</Adrnr>
<Bankk>0000</Bankk>
<Bankn>0000</Bankn>
<Bkont>0000</Bkont>
<Iban>ES0000</Iban>
<KoinhFi>ROBLES AVN</KoinhFi>
<Land1>TH</Land1>
<Landx>XXXXX</Landx>
<Name1>ROBLES AVN</Name1>
<Pstlz>0000</Pstlz>
<Stcd1>A0000</Stcd1>
<Stras>ROBLES AVN</Stras>
<Swift>XXXXX</Swift>
<Text1_052>ROBLES AVN</Text1_052>
<Zterm>Z000</Zterm>
</ZProveerDatosPagoProveed2Response>
</soap-env:Body>
</soap-env:Envelope>
The way I was able to do it is the following:
Include the two following jars from JAXB : jaxb-core.jar and jaxb-impl.jar
In the package-info.java file, set the following settings:
Supposing your namespace is "yournamespace"
#javax.xml.bind.annotation.XmlSchema(namespace = yournamespace,
xmlns = {#javax.xml.bind.annotation.XmlNs(prefix = "",
namespaceURI = yournamespace)},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.UNSET)
package com.ctpayment.admin;
It seems that the current implementation of java ignore the previous settings but the jaxb jars do not. I did not push my investigation further. Last but not least, you need the two jars in order to compile.
I'm trying to make a java webservice client. It's a very simple service that receives a String and return another String. I'm testing the service with soapUI and works perfectly but when I try to code it in java it fails.
Here is the code I'm using to call the service
QName QNAME_TYPE_STRING = new QName(nameSpaceURI,"string");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName(nameSpaceURI, webServiceMethod));
call.addParameter("buil:arg0", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(QNAME_TYPE_STRING, String.class);
String ret = (String) call.invoke(new Object[]{"PARAMETER VALUE"});
The endPoint variable points correctly to the URL of the service, and:
nameSpaceURI = "http://build.response.service/";
webServiceMethod = "buildResponse";
The thing is that the webService gets the parameter correctly but something happens on the response:
Caused by: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to
empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at javax.xml.stream.SerializableLocation#6fee8ce6
This is a sample of my request on soapUI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:buil="http://build.response.service/">
<soapenv:Header/>
<soapenv:Body>
<buil:buildResponse>
<buil:arg0>PARAMETER VALUE</buil:arg0>
</buil:buildResponse>
</soapenv:Body>
</soapenv:Envelope>
And this is a sample of the response on soapUI
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:buildResponse xmlns:ns1="http://build.response.service/">
<return xmlns="http://build.response.service/">
RESPONSE1,RESPONSE2,RESPONSE3
</return>
</ns1:buildResponse>
</soap:Body>
</soap:Envelope>
¿Ideas? I think this has something to do with the response, but I'm really a novice with webServices (I know... I know... the 21th century...).
Some more information: I'm not authorized to use wsdl2java nor publish the wsdl of the service (it's autogenerated anyway, I have nothing to do with it and it won't change). Sorry about this, I hope can help me despite this limitations.
Thanks!
God... it was so simple, made this little change on the call parameters:
call.addParameter(new QName(nameSpaceURI, "buil:arg0"),XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter(new QName(nameSpaceURI, "return"), XMLType.XSD_STRING, ParameterMode.OUT);
Now it works like a charm, hope this helps someone.
I need to send a SOAP Message with the following format (cut down from example I was given): -
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ret="http://www.another.com/ret"
xmlns:ser="http://www.another.com/ret/retTransaction/service"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ser:store>
<ret:retTransaction>
<ret:retailTransaction xsi:type="ret:NormalTransaction"> <ret:applicationId>POS</ret:applicationId>
</ret:retailTransaction>
</ret:retTransaction>
</ser:store>
</soapenv:Body>
</soapenv:Envelope>
The operation in question is "store". That operation has an "object" parameter in the proxy following Add Service Reference.
How do I ensure that a message with the correct format is sent? Particularly the multiple namespaces in the SOAP Envelope?
Thanks
i have implemented a webservice client that is used inside a webapplication (using Spring) and this client gets a response in which CXF bailsout and gives me an error message.
The error message is:
Server did not recognize the value of HTTP Header SOAPAction
I have found the problem but do not know what i can do to adjust my webservice response handling.
The xml response below works without any problems.
Works and is accepted ok!
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bar="http://www.dummyurl.com/service-v1.0/">
<soapenv:Header/>
<soapenv:Body>
<bar:StartSessionResponse>
<result>1</result>
</bar:StartSessionResponse>
</soapenv:Body>
</soapenv:Envelope>
The service actually returns:
Fails and gives me an error!
<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>
<StartSessionResponse xmlns="www.dummyurl.com/service-v1.0/">
<result xmlns="">1</result>
</StartSessionResponse>
</soap:Body>
</soap:Envelope>
The difference as far as i can see is in the placing of the
xmlns="www.dummyurl.com/service-v1.0/ element, in the success xml it is in the enveloppe, in the failed xml it is on the reponse method.
Is there a way that i can convince CXF to accept the response? Or is the service giving back an abnormal result?
The service is giving back a wrong response in the second case, assuming that the first response is proper.
In the first case "www.dummyurl.com/service-v1.0/" is the namespace of your elements - StartSessionResponse, result is not qualified with the namespace. In the second case, the StartSessionResponse has the same namespace as the first sample, but the result has a different namespace altogether, taking out xmlns="" for result will make the xml consistent.