Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How can I create a simple soap client servlet to send XML?

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all-

After quite a bit of messing around to get Apache Muse working for a subscribe notify request I have run into quite a few problems: wsdl2java errors , authentication support and other issues. It seems that the Muse project is no longer even supported.

Since the msg I want to send is sent rarely (basically to turn on subscription notification) I want to send the xml manually through a soap client. I have the correct soap xml (including soap header) from using soapUI to test the service.

Now I want to send the soap msg using a servlet.

There must be a straightforward way to do this but I can't find one. I'm using Jboss 4.2 (JAX-WS which was not compatible with Muse) and the Jboss Seam app framework as well, although I can and probably will skip seam to get this working.

I just want to fire off a prebuilt soap msg.

thanks for any suggestions

Max
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Have you considered Apache HttpClient?
Strictly speaking, if you just want to send a HTTP request carrying a payload (the SOAP message), then Java SE is sufficient.
Are there any requirements regarding interpreting the response?
Best wishes!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can certainly use an existing copy of the XML client SOAP message as a template and send the request with HttpClient.

I did exactly that for a client, saving a whole bunch of fiddling with AXIS2 classes. I modified the template by replacing values with "@1" *@2" etc placeholders which got replaced with new values while sending the request.

Bill

 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill/Ivan - Thanks for the replies

HttpClient - Great suggestion. I have used that in the past and had forgotten about it.

I do need to read the response to ensure the request was successful, which I can do.

HttpClient may well be the solution since I have to embed WSSE security info in the SOAP header and configuring security for this one message is a royal pain.
This msg will basically be sent once. If we ever need to turn subscriptions off, I will have another servlet to send an unsubscribe.

thanks again!
Max
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill-

I just read another post you commented on regarding this subject a couple of years ago:

"httpclient for accessing webservice"

You suggested using HttpURLConnection - I think this is the approach I want, correct, since I am invoking a web service - and I need to read the response?
I need to send via a Post.

Max
 
For my next trick, I'll need the help of a tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic