Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServiceMode Message and Provider<SOAPMessage>

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have this:


My question is if I choose Service.Mode.MESSAGE, must I implement Provider<SOAPMessage> ?
From Ivan's notes p.161, I choose Service.Mode.MESSAGE instead of Service.Mode.PAYLOAD, and I implement Provider<Source>, just like what Ivan does.
However, I got a null pointer exception from the client side because the server expects to have a SOAP envelope.

I wonder if Service.Mode.MESSAGE and Provider<SOAPMessage> must be used together and Service.Mode.PAYLOAD and Provider<Source> must be used together.

 
phani bhushan reddy
Greenhorn
Posts: 27
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please copy your code here for any inputs ? If you are working with Mode.MESSAGE, then client will work at SOAP Envelope that's the specification.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code from Ivan's notes. The artifacts ReverseStringReq and ReverseStringResp are generated from the wsdl provided by Ivan. They are not shown here.


The client code I created:


Error message from client side :


Error message from server side:


How can I create the SOAP messages with the request and response inside the SOAP messages ?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Himai,

You are sending a ReverseStringReq as JAXB object (mashalled to XML) over the wire. This ReverseStringReq is (probably) not a SOAPMessage object and that is why you get the UnmarshalException on the server side (as the server thinks it is getting an SOAPMessage because of the Mode.MESSAGE). You can use JAXB object in combination with the dipatch client and Mode.MESSAGE though:

For JAXB objects (from JAX-WS 2.x)
JAXB Objects Use of JAXB allows clients to use JAXB objects generated from an XML Schema to create and manipulate XML representations and to use these objects with JAX-WS without requiring an intermediate XML serialization. JAXB objects may be used with any protocol binding in either message or message payload mode.


Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits.
So, my next questions is how can I convert ReverseStringReq JAXB element into SOAPMessage ? Or, it is not possible to do that?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himai Minh wrote:Thanks Frits.
So, my next questions is how can I convert ReverseStringReq JAXB element into SOAPMessage ? Or, it is not possible to do that?

No that is not possible.

In fact using the Mode.MESSAGE in combination with JAXB is a bit tricky (because there is no @XmlRootElement in the SOAPMessage class), you better stick to Mode.PAYLOAD.

Regards,
Frits
 
a sarkar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himai Minh,
You can find an example of Mode.MESSAGE with JAXB here on my GitHub. HTH.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2535
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a sarkar wrote:Himai Minh,
You can find an example of Mode.MESSAGE with JAXB here on my GitHub. HTH.

Nice example, but we were talking about an example of:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic