-1
String example =
        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><ns2:farm xmlns:ns2=\"http://adamish.com/example/farm\"><horse height=\"123\" name=\"glue factory\"/></ns2:farm></soapenv:Body></soapenv:Envelope>";

Here is my soap xml in string format how i need to form it in a Farm object .Farm is my custom class,Any library is readly available

After Using This Code m getting the exception

SOAPMessage message = MessageFactory.newInstance().createMessage(null,
                new ByteArrayInputStream(example.getBytes()));
        Unmarshaller unmarshaller = JAXBContext.newInstance(Farm.class).createUnmarshaller();
        SubscribeProductReq farm = (Farm)unmarshaller.unmarshal(message.getSOAPBody().extractContentAsDocument());

unexpected element (uri:"http://yyyyyy.yyyyy*********", local:"farm"). Expected elements are <{}farm>

1

1 Answer 1

-1

You don't need to do much:

There are two ways to generate Client side java code for SOAP:

1) You must be getting this xml from some URL. So, Maven plugin gives you control over to generate jar from URL for SOAP.

2) You can diretly place SOAP xml into a file and put that file path in maven pom. Maven will generate client jar using Apache CXF.

Visit https://www.jetbrains.com/help/idea/generate-java-code-from-wsdl-or-wadl-dialog.html

visit https://objectpartners.com/2010/11/25/leveraging-apache-cxf-and-maven-to-generate-client-side-web-service-bindings/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.