[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to print the XML request from Axis 1.4 stub

Posted on 2009-05-17
6
Medium Priority
?
5,625 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

649 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