Solved

how to print the XML request from Axis 1.4 stub

Posted on 2009-05-17
6
5,041 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lines Not Lining Up 2 87
How to replace a token in a string with square brackets? 2 87
Stupid git question 2 114
Grunt Copy file to another destination. 1 81
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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

749 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