• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to get SOAP request XML for a web service call

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a standalone Java application running on a remote machine that consumes a web service.The web service is developed by some other group of organization.The standalone java code that consumes web service was written by me and then put on a remote machine.For this post's purpose,let us assume,this standalone java code is executed by a background script periodically.

I need to know the SOAP request XML that is being sent by this standalone Java application.There is some issue with the way my standalone java code is calling web service and I need to debug this.
Somehow,my code is not able to get proper response from web service and I need to know why.I am ok with writing some Java code to achieve this.

I have done enough research on net and this is my last resort.I looked at tcpmon,soapui,fiddler - none of them can be used here since there is no client side URL or port!
This is really urgent.If some one can help me quickly,it will really be appreciated.
Thanks!!
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More efficient ways of debugging SOAP based Web Services from PHP ... might help...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

there is no client side URL or port!



This is the client that you wrote we are talking about? How do you make a SOAP request without a URL or port?

If you can't get at the remote machine to use SOAPui or similar, and the web service is not under your control, what CAN you get at?

Bill
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:

there is no client side URL or port!



This is the client that you wrote we are talking about? How do you make a SOAP request without a URL or port?

If you can't get at the remote machine to use SOAPui or similar, and the web service is not under your control, what CAN you get at?

Bill


William,that is right.

How do you make a SOAP request without a URL or port?

My code is a standalone code that needs to read messages from a JMS queue.It reads the message and call the Web Service.Why does Client code need to have URL or port?

If you can't get at the remote machine to use SOAPui or similar, and the web service is not under your control, what CAN you get at?
That is where I need help - What do I do here?

 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that the web service is not responding to HTTP SOAP requests but to JMS SOAP messages?

If so, can you get at the configuration of the JMS server or otherwise change the configuration so that the JMS message exchange is no longer point-to-point but publish-subscribe? That way you could run a separate process subscribing to all of the requests and responses.

My code is a standalone code that needs to read messages from a JMS queue.It reads the message and call the Web Service.Why does Client code need to have URL or port?



"Client code" - I am getting confused here - how many entities are we talking about? Which ones can you add debugging code to?

If the "web service" is responding to HTTP requests, there must, by definition, be a port and url involved.

Bill
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Are you saying that the web service is not responding to HTTP SOAP requests but to JMS SOAP messages?

If so, can you get at the configuration of the JMS server or otherwise change the configuration so that the JMS message exchange is no longer point-to-point but publish-subscribe? That way you could run a separate process subscribing to all of the requests and responses.

My code is a standalone code that needs to read messages from a JMS queue.It reads the message and call the Web Service.Why does Client code need to have URL or port?



"Client code" - I am getting confused here - how many entities are we talking about? Which ones can you add debugging code to?

If the "web service" is responding to HTTP requests, there must, by definition, be a port and url involved.

Bill



Sorry if I got you confused.Web service that my code accesses does have URL and port.My code is client code (since it accesses web service) and it is a standalone Java program.This Java program cannot be accesses through a URL/port.Let me know if you have any more questions.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

my code accesses does have URL and port.My code is client code (since it accesses web service) and it is a standalone Java program.This Java program cannot be accesses through a URL/port



This statement makes no sense. You wrote code that "does have URL and port" but "cannot be accesses through a URL/port"

Either it makes use of a URL or not!

It sounds to me like you could create a sort of proxy application - change the URL in your client to point to the proxy - proxy would record the entire SOAP request message and send it on to the web service - receive the response, log it, and send it on to your client.

Bill
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:

my code accesses does have URL and port.My code is client code (since it accesses web service) and it is a standalone Java program.This Java program cannot be accesses through a URL/port



This statement makes no sense. You wrote code that "does have URL and port" but "cannot be accesses through a URL/port"

Either it makes use of a URL or not!

It sounds to me like you could create a sort of proxy application - change the URL in your client to point to the proxy - proxy would record the entire SOAP request message and send it on to the web service - receive the response, log it, and send it on to your client.

Bill



Well,any web service is bound to have URL and port.My code consumes one of the web services.
Coming to your second part - you mean to say - I need to create a proxy application?How do I do that?
And this proxy application will call the actual web service?These are too many unknowns to me.But I think you are coming to the right point - because someone else in my office was talking something like that - but he won't help in figuring out minute details.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right! The normal way to monitor the exact text sent and received by a SOAP client would be SOAPui or TCPMON, but as I understand it, you cant use them because your client is remote and both of those require user window input.

One possibility would be to set up the remote machine to work with Microsoft's Remote Desktop so you could run SOAPui or TCPMON as if you were looking at the remote machine's desktop. This works surprisingly well.

If not, you need to create the same functionality but with logging instead of a GUI interface.

Essentially the SOAP client would address a localhost port which your proxy would answer, capture the complete request, log it and then send it to the actual web service address. This is going to involve you in Java socket programming and multiple Threads.

You might want to download the TCPMON code for inspiration and study.

Bill
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are very high level details - I was looking for a code example that I can use for my case.
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I get help from someone?
 
Greenhorn
Posts: 16
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jitesh,

Let us see if this approach helps you.

You wrote that you are consuming a webservice in your code.
My question is : Are you consuming through a wsdl or it is a restful-ws ?
********************************************************************************************************
If you have a wsdl then one of the easiest way is to use wsdl2java tool in Apache Axis2.
Using this wsdl2java tool you can generate wsdl-mapped java classes(i.e. stub), which you can use in your client code.
One more important advantage with this approach is within this stub you can put sysouts to print the soap requests and responses.

Or you can obtain wsdl by appending "?wsdl" to your webservice URL. If you put this entire URL in IE or firefox you should see a wsdl doc. If you go successful then you can use same URL to generate java stubs.
********************************************************************************************************
And if you are using restful-ws then approach would be different one .
********************************************************************************************************
So first clarify on the things above then we can proceed further.
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using soap web service and I have generated Java classes using wsdl.Where and how do I put sysouts to get soap xml?
 
Naren Mane
Greenhorn
Posts: 16
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jitesh,

OK as you told you are using a wsdl to generate java classes, then one approach to see soap request and response logs is to use APACHE AXIS2 to generate java stubs(i.e. use wsdl2java tool).
*******************************************************************************************************
This java stub will contain auto-generated methods that are mapped to wsdl you used to generate java stub. In each method you will find something like :


org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(.....some auto-generated signature here.....);
//Add sysout to print SOAP request log
System.out.println("SOAP Request: "+env.getBody());
.....
.....
.....
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
//Add sysout to print SOAP response log
System.out.println("SOAP Response: "+_returnEnv.getBody());

*******************************************************************************************************
Remember this logic is feasible only if you have a java stub generated using wsdl2java tool from Apache Axis2.
Let me know if this approach helps you .
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Naren - it makes sense.I will see if it can be done.
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic