Working with an old wsdl file
generated with AXIS
to make it work with spring ws. After doing some tweaks and all, i could generate the java sources with the old wsdl.
Now i am trying to make a request from soap UI
, But request values are shown as null in endpoint
method
. Request is coming in backend
properly but not values
.
WSDL file
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
<soapenv:Header/>
<soapenv:Body>
<onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="onl:SummaryObject">
<docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
<amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
<duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
<reference xsi:type="xsd:long">?</reference>
<sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
<startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
</in0>
</onl:getSummary>
</soapenv:Body>
</soapenv:Envelope>
Soap Request:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
<soapenv:Header/>
<soapenv:Body>
<onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="onl:SummaryObject">
<docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
<amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
<duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
<reference xsi:type="xsd:long">121212121</reference>
<sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
<startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
<visibility xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</visibility>
</in0>
</onl:getSummary>
</soapenv:Body>
</soapenv:Envelope>
Endpoint Method:
@PayloadRoot(namespace = NAMESPACE_URI, localPart ="getSummary")
@ResponsePayload
public JAXBElement<EObjects> getSummary(@RequestPayload SummaryObject summaryObject) {
System.out.println("Am done with this"+summaryObject.getDocId());
ObjectFactory factory = new ObjectFactory();
EObjects objects = factory.createEObjects();
QName qname = new QName("http://online.mysite.com", "eobjects");
return new JAXBElement(qname, EObjects.class, objects);
}
WSDL generated in axis 1
is no longer been supported by spring ws or CXF
. So that generated java classes from WSDL wont have required information that is needed for unmarshelling
of request by JAXB
in spring
. Thus request
object will come as null
.
I have done a work around which has 2 things to do
@XmlRootElement(name="getSomething",namespace = "http://yoursite.com")
code
SoapMessage message = (SoapMessage) messageContext.getRequest();
ByteArrayOutputStream out = new ByteArrayOutputStream();
message.writeTo(out);
String strMsg = new String(out.toByteArray()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.parse(new InputSource(new StringReader(strMsg)));
Node getrequestObject = d.getElementsByTagName("yourtag").item(0);
JAXBContext jc = JAXBContext.newInstance(MyRequestObject.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<SummaryObject> je = unmarshaller.unmarshal(new
DOMSource(getrequestObject), MyRequestObject.class);