This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

ServiceMode Message and Provider<SOAPMessage>

 
Ranch Hand
Posts: 1742
12
  • 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.

 
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: 1742
12
  • 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 ?
 
Creator of Enthuware JWS+ V6
Posts: 3289
296
Android Eclipse IDE Chrome
  • 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: 1742
12
  • 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
Posts: 3289
296
Android Eclipse IDE Chrome
  • 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
 
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
Posts: 3289
296
Android Eclipse IDE Chrome
  • 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:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!