Solved

how to print the XML request from Axis 1.4 stub

Posted on 2009-05-17
6
4,605 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
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 500 total points
Comment Utility
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
Comment Utility
thanks shivaspk, but when I am trying this,  _call.getMessageContext() is throwing NullPointerException.  Any clues?

0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:LeoKris
Comment Utility
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
Comment Utility
Siva, It worked.. thanks a lot.
0
 

Expert Comment

by:Win Lord
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now