File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Unable to send a SOAP request to a service implementing Provider Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Unable to send a SOAP request to a service implementing Provider" Watch "Unable to send a SOAP request to a service implementing Provider" New topic
Author

Unable to send a SOAP request to a service implementing Provider

Rajani Gummadi
Ranch Hand

Joined: Dec 17, 2010
Posts: 48
Hi,

I have my xsd and wsdl as defined below

Calculator.xsd


Calculator.wsdl


as seen above, I'm using RPC Literal type style.

I ran the xjc against the schema and classes AddRequestType.java AddResponseType.java are created along with ObjectFactory.java and package-info.java

Now my service class is as below


I see an exception is thrown while unmarshalling.


From the code the UnMarshaller is expecting a addRequest and addResponse, but my SOAP request is



Considering the fact that, I started WSDL first approach, can some one guide me, if my WSDL is in fact correct. If yes, what else I'm doing wrong here. I knew that JAXB objects were created based on xsd and the namespace and elements are different, but given a fact that JAXB objects are created separately after WSDL and xsd are designed, what else do I need to make for this to work.

Please advise.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Could you enclose a copy of an entire SOAP request to your web service? I can recommend using soapUI, both for testing and for seeing entire requests and responses.
The correctness of the request depends on namespace declarations, something left out of your request.
In my electronic book there is an example of how to implement a web service using Provider, as well as a matching client.
The book can be downloaded freely from: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Rajani Gummadi
Ranch Hand

Joined: Dec 17, 2010
Posts: 48
Thanks Ivan,

From SOAPUI, the SOAP request is



I did not get any response for this, as I believe, due to the run time exception

[com.sun.istack.XMLStreamException2: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.example.org/Calculator/", local:"addNumbers"). Expected elements are <{http://www.example.org/Calculator}addRequest>,<{http://www.example.org/Calculator}addResponse>]

But I have not hardcoded the request and response and SOAPUI generated the request based on WSDL. Do I need to fix anything in my WSDL for this to get to work ?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Take a look at the JAXB bean classes generated by XJC.
XJC does not understand that you are using RPC/Literal, but creates one class for the addRequestType and another for the addResponseType.
These two classes will result in <addRequest> and <addResponse> elements in the request - something that your (RPC) service does not expect.
Best wishes!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unable to send a SOAP request to a service implementing Provider