I have the following issue with CXF version 2.7.7-redhat-1, that seems like a bug in the library.
With the following request:
<?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:Body>
<authorizePayment xmlns="http://ejb.example.org">
<request xmlns="">
<role xmlns:q1="http://to.homepay.example.org" xsi:type="q1:CustomerTO">
<user>7C742</user>
</role>
<error>
<errorCode>1</errorCode>
<errorMessage>1</errorMessage>
</error>
<status>
<code>1</code>
</status>
<ordAccount>1</ordAccount>
<logId>374216011815223570893830967949</logId>
<signMethod>1</signMethod>
<lang>1</lang>
<terminalId>1</terminalId>
<terminalLocation>Earth</terminalLocation>
</request>
</authorizePayment>
</soap:Body>
</soap:Envelope>
I get the following error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"http://ejb.example.org", local:"request"). Expected elements are <{}request></faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
From the request you can clearly see that the namespace of the request is "" overridden from its parent.
If I change the request to:
<?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:Body>
<aa:authorizePayment xmlns:aa="http://ejb.example.org">
<request xmlns="">
<role xmlns:q1="http://to.homepay.example.org" xsi:type="q1:CustomerTO">
<user>7C742</user>
</role>
<error>
<errorCode>1</errorCode>
<errorMessage>1</errorMessage>
</error>
<status>
<code>1</code>
</status>
<ordAccount>1</ordAccount>
<logId>374216011815223570893830967949</logId>
<signMethod>1</signMethod>
<lang>1</lang>
<terminalId>1</terminalId>
<terminalLocation>Earth</terminalLocation>
</request>
</aa:authorizePayment>
</soap:Body>
</soap:Envelope>
The call works. I need a way to fix this issue server side, the client can't be modified to change the request.
Versions:
JBoss AS release: 7.3.4.Final-redhat-1 "Janus"
JBoss AS product: EAP 6.2.4.GA
java.version: 1.7.0_91
Set the elementFormDefault=qualified in the wsdl, generate the artifacts and redeploy the application.
Qualified means that local element declarations (xs:element within xs:complexType) refers to elements in the target namespace of the schema. Without it, they refer to elements in no namespace.
Related
I have the following file that I cURL:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ProcessMessage xmlns="http://www.user.com/test/">
<envelope>Encoded XML request message will go here</envelope>
</ProcessMessage>
</soap:Body>
</soap:Envelope>
The full error I get is this:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
When I use the file with a CDATA element then everything works as expected.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ProcessMessage xmlns="http://www.user.com/test/">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<envelope>Encoded XML request message will go here</envelope>
]]>
</ProcessMessage>
</soap:Body>
</soap:Envelope>
Any idea how I can accept an XML file without the CDATA part?
quote: "Only one XML declaration is permitted in well-formed XML, and it must be at the top if anywhere."
See: https://stackoverflow.com/a/20251895/3710053
So if you could get rid of that second <?xml version="1.0" encoding="UTF-8"?> your okay.
I need to generate a soap request like the below one :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document xmlns:ns2="http://www.xyz" xmlns="thsss.738.syhd.738">
<Customer>
<Group>
<Message>Something</Message>
</Group>
</Customer>
</Document>
But the request getting generated is as below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://eygyjdg.dbajshb/" xmlns:thss="thsss.738.syhd.738" xmlns:xyz="http://www.xyz">
<soapenv:Header/>
<soapenv:Body>
<Document>
<Customer>
<Group>
<Message>Something</Message>
</Group>
</Customer>
</Document>
</soapenv:Body>
</soapenv:Envelope>
Hence i get a namespace on the "Document" element, is not a valid SOAP version
Can you please tell me how to go about this.
I would like to find out the best way to parse responses using oasis xsd. I have the following response xml string but am not sure how to parse it, i tried copying the xsd from oasis but it fails to create jaxb objects. This is the xml response data:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-521833581">
<wsu:Created>2017-09-07T00:00:02.002Z</wsu:Created>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<soap:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:c="urn:schemas-visa-com:transaction-data-1.0">
<faultcode>wsse:FailedCheck</faultcode>
<faultstring>
Security Data : UsernameToken authentication failed.
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Found a simple solution, not implemented this way ofcource, just an illustration:
SOAPBody body = soapResponse.getSOAPBody();
if(body.hasFault()){
LOG.debug("HAS LOG FAULT, LETS SEE WHAT ELSE...");
LOG.debug("getFaultCode" + body.getFault().getFaultCode());
LOG.debug("getFaultString" + body.getFault().getFaultString());
}
<soap:Envelope xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsrl="http://docs.oasis-open.org/wsrf/rl-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns1="http://workflow.comarch.com/SDService_ws" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsrp="http://docs.oasis-open.org/wsrf/rp-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<soap:Body wsu:Id="myBody-1491835424">
<ns1:listProcessesResponse>
<listProcessesReturn xsi:nil="true" xsi:type="tns:listProcessesReturn"/>
</ns1:listProcessesResponse>
</soap:Body>
</soap:Envelope>
What is wrong with that SOAP response? I'm using SoapUI to verify SOAP Answers. It checks if received response is compatible with WSDL standards. So when I run validation in SoapUI it produces the following error.
java.lang.String cannot be cast to org.apache.xmlbeans.XmlError
The message itself looks like a bug in SoapUI's error handling
What is wrong with that SOAP response?
Your schemaLocation is wrong
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/"
you have the same URI in there twice
Also, you are using the namespace tns without having defined it in
xsi:type="tns:listProcessesReturn"
I tried sending a SOAP message using saaj, but I can't add multiple headers element, how do I send a SOAP message like the following?
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"xmlns:ns1="urn://xparcws/ticket" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn://xparcws/session" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Header>
<ns2:Session><scalar>asd</scalar>
<sessionkey>67e61b5b36e3c989d91eba0d8621</sessionkey>
</ns2:Session>
</env:Header>
<env:Body>
<ns1:TicketService.requestTicket env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<ticketid xsi:type="xsd:long">1261534</ticketid>
</ns1:TicketService.requestTicket></env:Body>
</env:Envelope>