Solved

how to print the XML request from Axis 1.4 stub

Posted on 2009-05-17
6
5,251 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 500 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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 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