I have to send an xml content into soap message.
The web service rejects the request because there is an extra prefix in the root element of the body.
The generated soap message is :
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns3:rootElement xmlns:ns2="http://webserviceprovider/result" xmlns:ns3="http://webserviceprovider/request">
--- other data
</ns3:rootElement>
</S:Body>
What is expected by the web service is a soap message without prefix (ns3):
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<rootElement xmlns:ns2="http://webserviceprovider/result" xmlns:ns3="http://webserviceprovider/request">
--- other data
</rootElement>
</S:Body>
Thanks.
Related
I am just trying to return a String[] from a #webMethod to the ws swing client. The problem is that it is not returning anything. When I test the web service it shows
Method returned
net.java.dev.jaxb.array.StringArray : "net.java.dev.jaxb.array.StringArray#2f741802"
SOAP Request
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<S:Body>
<ns2:getEmployeeNames xmlns:ns2="http://employee.bank.com/"/>
</S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<S:Body>
<ns2:getEmployeeNamesResponse xmlns:ns2="http://employee.bank.com/">
<return>
<item>73869</item>
</return>
</ns2:getEmployeeNamesResponse>
</S:Body>
</S:Envelope>
the web service method is
public String[] getEmployeeNames()
{
String[] nameList = ........;
return nameList;
}
I am getting soap response from web service. I need to parse to get the value inside the node. Please provide some code to parse the soap response.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:Response xmlns:ns3="http://www.example.org/Response" userid="100">
<name date="23-10-2013">Sample</name>
<name date="02-09-2013">Hello</name>
</ns3:Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The service at this address http://www.cs12333.com:8001/Service/PersonSearchService returns the following XML:
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:findPersonListResponse xmlns:ns2="http://service.person.search/">
<return>
<result>true</result>
<resultList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:grxxBean">
<aab001>cooperation</aab001>
<aac001>34305742</aac001>
<aac002>430423198906237024</aac002>
<aac003>licong</aac003>
<aac004>2</aac004>
<aac031>2</aac031>`
<pwd>1</pwd>
</resultList>
</return>
</ns2:findPersonListResponse>
</S:Body>
</S:Envelope>
I'm reading the values like this:
dom = DocumentHelper.parseText(result);
Element root=dom.getRootElement();
The root's value is "org.dom4j.tree.DefaultElement#db23f1 [Element: <S:Envelope schemas.xmlsoap.org/soap/envelope/attributes: []/>]".
How do I get the value of tag <aac003>?
Try this expath to get <aac003> value
/*:Envelope/*:Body/*:findPersonListResponse/*:return/*:resultList/*:aac003
I am developing a web service client.
Unprocessed 'mustUnderstand' header element: {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security
Wherever it works fine with SoapUI, returns proper response with following header:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<S:Header>
<wsse:Security S:mustUnderstand="1">
<wsu:Timestamp wsu:Id="XWSSGID-13660988101781895308327" xmlns:ns15="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope">
<wsu:Created>2013-04-16T08:02:05Z</wsu:Created>
<wsu:Expires>2013-04-16T08:07:05Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</S:Header>
I can not use wsHttpBinding. My request is:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>wstest</wsse:Username>
<wsse:Password>wstest</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<-- client method call implementation>
</env:Body>
</env:Envelope>
please help me on this.
in the getHeaders() method you would need to return a XML element that would contain the root element. In this case, I would build a QName element with the following instantiation and add to a Set and return that in the getHeaders element:
#Override
public Set<QName> getHeaders(){
Set<QName> headers = new HashSet<QName>();
QName ck = new QName("http://coldyak.com", "coldyak", "cyk");
headers.add(ck);
return headers;
}
This is all that's needed to handle the mustunderstand attribute. It's sort of like a contract that enforces the webservice to process the header element.
I have been trying to send a request through soapui and I always keep getting the following error message:
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Failed to process SOAP request. SOAP body not in UTF-16.</faultstring>
<detail>
<wsdl_ops:error>
Failed to process SOAP request. SOAP body not in UTF-16.
</wsdl_ops:error>
</detail>
</soap:Fault>
</soap:Body>
Has anyone run into the same issue before?
UPDATE:
I changed the encoding to UTF-16 and it worked for me. Now, when I send the request I get the following error instead:
REQUEST:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.broadsign.com/wsdl_ops">
<soapenv:Header/>
<soapenv:Body>
<ns1:request not_modified_since="1970-01-01T00:00:00" token="0" requestid="1" version="4" name="category_mgr_list">
<category domain_id="1719213" />
</ns1:request>
</soapenv:Body>
</soapenv:Envelope>
RESPONSE:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl_ops="http://www.broadsign.com/wsdl_ops">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Invalid request.</faultstring>
<detail>
<wsdl_ops:error>Invalid request.</wsdl_ops:error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What am I missing? :(
Sounds like the service is expecting the request to be encoded as UTF-16. Validate your request and try setting the encoding in the request properties. Failing that, edit your question with the raw inputs and outputs.