Capturing the HTTP Request from an Axis2 Client Program

This section provides a tutorial example on how to capture the HTTP request generated from an Axis2 client program with the socket server test program.

In order to run SocketRequestResponseServer.java to serve Axis2GetExchangeRateClient.java, I need to do these steps:

1. Prepare a mock HTTP response file, GetExchangeRate_WSDL_11_SOAP_11_RPC.res, to be used by SocketRequestResponseServer.java:

HTTP/1.0 200 OK
Server: SocketRequestResponseServer.java
Content-Length: 514
Connection: close
Content-Type: text/html;charset=utf-8

<soapenv:Envelope
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:hy="http://www.herongyang.com/Service/">
  <soapenv:Header/>
  <soapenv:Body>
    <hy:GetExchangeRateResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <hy:ratePart xsi:type="xsd:decimal">123.14</hy:ratePart>
    </hy:GetExchangeRateResponse>
  </soapenv:Body>
</soapenv:Envelope>

2. Run SocketRequestResponseServer.java in separate command line window to wait for the client program:

C:\herong>java SocketRequestResponseServer \
   GetExchangeRate_WSDL_11_SOAP_11_RPC.res server.req

Listening at 8888

3. Change the local WSDL document, /herong/GetExchangeRate_WSDL_11_SOAP_11_RPC.wsdl, to use the local address location:

<soap:address location= "http://localhost:8888/"/>

4. Run Axis2GetExchangeRateClient.java again in a different command line window:

C:\herong>java -cp .;\local\axis2\lib\* Axis2GetExchangeRateClient local

123.14

5. Go to the SocketRequestResponseServer.java window and check the output file:

C:\herong>java SocketRequestResponseServer
   GetExchangeRate_WSDL_11_SOAP_11_RPC.res server.req
   
Listening at 8888
Connection received from /127.0.0.1
Request length: 524
Response length: 654

C:\herong>type server.req
POST / HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.herongyang.com/Service/getExchangeRate"
User-Agent: Axis2
Host: localhost:8888
Content-Length: 339

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Header/>
 <soapenv:Body>
  <GetExchangeRate xmlns="http://www.herongyang.com/Service/">
   <arg0 xmlns="">USD</arg0>
   <arg1 xmlns="">JPY</arg1>
   <arg2 xmlns="">2018-08-08</arg2>
  </GetExchangeRate>
 </soapenv:Body>
</soapenv:Envelope>

Now I can see what Axis2GetExchangeRateClient.java is doing in HTTP request:

Last update: 2018.

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

 WSDL 2.0 Document Examples with SOAP Binding

 Using WSDL Document in Java Apache Axis2/Java for WSDL

 Apache Woden for WSDL Documents in Java

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

Apache Axis2/Java for WSDL 1.1

 Creating Service Client with WSDL 1.1 Document

 org.apache.axis2.client.Options - Operation Client Options

 sendReceive() Method - Invoking a Named Operation

 Turning Off the Chunked HTTP Flag

 AXIOM (AXIs Object Model)

 Axis2RegistrationClient.java - document/literal Style

 org.apache.axis2.rpc.client.RPCServiceClient Class

 Axis2GetExchangeRateClient.java - rpc/encoded Style

 SocketRequestResponseServer.java - Socket Server Testing Program

Capturing the HTTP Request from an Axis2 Client Program

 Using WSDL2Java to Generate Web Service Stub Classes

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

 WSDL Related Terminologies

 Outdated Tutorials

 References

 Full Version in PDF/EPUB