I’ve invoking a document-style SOAP web service. It works with SOAP UI, but I’m getting an error trying to invoke it programaticaly.
Here is the error I’m getting from the server:
<SubmitRequestDocResponse xmlns="http://tripauthority.com/hotel">
<SubmitRequestDocResult>
<ArnResponse xmlns:ns2="http://tripauthority.com/hotel" xmlns="">
<Error>
<Message>
Request is not valid. Details: The
'http://tripauthority.com/hotel:ArnRequest'
element is not declared.
</Message>
</Error>
</ArnResponse>
</SubmitRequestDocResult>
</SubmitRequestDocResponse>
The code invoking it looks like:
ARequestDoc requestDoc = objectFactory.createSubmitRequestDocARequestDoc();
ArnRequest request = requestFactory.createArnRequest();
requestDoc.getContent().add(request);
SubmitRequestDocResult response =
soap.submitRequestDoc("id", "username", "password", requestDoc);
And the classes used are organized and annotated:
package com.company.server.ws:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"siteID",
"aUserName",
"aPassword",
"aRequestDoc"
})
@XmlRootElement(name = "SubmitRequestDoc")
@XmlSeeAlso(ArnRequest.class)
public class SubmitRequestDoc { // Stuff... }
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
public static class ARequestDoc { // Stuff ... }
package com.company.server.ws.request:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"availability",
"rateDetails",
"reservation",
"cancellation"
})
@XmlRootElement(name = "ArnRequest")
public class ArnRequest { // Stuff ... }
Additionally, com.company.server.ws has the following package-info.java:
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://tripauthority.com/hotel",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.company.server.ws;
Additionally, for what it’s worth, here’s the WSDL and the XSD for the Request
Does anyone have any idea what I can do to get this message to send properly? I can send a hardcoded string request using SOAP UI and it works just fine.
Thanks
Edit
For what it’s worth, my guess so far has been that it might go through if I could somehow send the ArnRequest portion without any namespace declared, if there’s any way to do that, but this is just a guess and any insight is appreciated.
Figured out a way to make it work.
I added another
package-info.javafile under com.company.server.ws.request which basically declared no namespace for theArnRequestobject, like so:If I understand this correctly, it’s telling the serializer to set ‘no’ namespace for the
ArnRequestobect, and turns off the validation by setting form default to UNQUALIFIED.I’m not sure exactly what this is doing, but it definitely works now, so any more insight would be appreciated.