?
Solved

how to print the XML request from Axis 1.4 stub

Posted on 2009-05-17
6
Medium Priority
?
5,394 Views
Last Modified: 2016-09-22
Hi, I have used Axis-1.4 libraries (WSDL2Java specifically) to generate the binding classes. Once I have the stub, I create an instance of required classes, then set the values of the parameters for the method exposed by Web Service, and finall invoke the "call" method.

Is there a way I can see/print the SOAP request (that is actually sent to the Web Service) which is generated by the Axis engine behind the scene?

Thanks
0
Comment
Question by:LeoKris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 2000 total points
ID: 24409623
you can do something like this, But please note this works only after the call is done/complete else returns null

In you xxxxxSoapBindingStub class in the particular method where u wanna capture req/res xml just add the following lines after the invoke() call.

Here is a sample from my helloService which takes a name.
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {name});
         System.out.println(_call.getMessageContext().getRequestMessage().getSOAPPartAsString());
 System.out.println(_call.getResponseMessage().getSOAPPartAsString());

Open in new window

0
 

Author Comment

by:LeoKris
ID: 24410742
thanks shivaspk, but when I am trying this,  _call.getMessageContext() is throwing NullPointerException.  Any clues?

0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 24410820
You need to add these in you Soap Binding Stub class for a particular operation that also after this statement.
java.lang.Object _resp = _call.invoke(new java.lang.Object[] ...

This is just for logging purpose only, if you can show me you stub class or mail me your code may be I can help better.

Regards,

Siva
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

Author Comment

by:LeoKris
ID: 24417726
Thanks Siva, I am trying to make it work in the lines you have suggested. I will send you the code in case it does not work.
0
 

Author Comment

by:LeoKris
ID: 24428762
Siva, It worked.. thanks a lot.
0
 

Expert Comment

by:Win Lord
ID: 41810234
Can you check for me, raw request i printed via Axis is:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><ns1:AuthHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://tempuri.org/"><ns1:Username>test.bidv</ns1:Username><ns1:Password>test</ns1:Password></ns1:AuthHeader></soapenv:Header><soapenv:Body><TracuuKhachhangTheoID xmlns="http://tempuri.org/"><p_tinhthanh_id>4</p_tinhthanh_id><p_khachhang_id>33213</p_khachhang_id></TracuuKhachhangTheoID></soapenv:Body></soapenv:Envelope>

And response is : Wrong userName, Password, errorCode = 1

But i tried same request in Postman tools, it right userName and password, and have another error (you can see this image in: http://prntscr.com/ckxpqn )

So how to i fix it to have pass userName and password used Axis?
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question