Think Good
View list of my frequently visited bloglines
Tags - Categories : All | General | Software Development

This is a soap request sent from Java Servlet to call the Calucator Webserive.
The below snippet was taken using TCPtrace.
Server: ServletExec, IIS, Apache Axis.
Client: Java Servlet. JDK 1.4

Raw HTTP with Authentication

POST /axis14/Calculator.jws?wsdl HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8090
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 400
Authorization: Basic YmFsYWppZGw6bG9nc2FuYmFs

<?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:Body>
 <add soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <op1 xsi:type="xsd:int">5</op1>
 <op2 xsi:type="xsd:int">5</op2>
 </add>
</soapenv:Body>
</soapenv:Envelope>
 
Java Servlet based client code snippet
try {
 String endpoint = "http://localhost:8090/axis14/Calculator.jws?wsdl";

 Integer i1 = new Integer(5);
 Integer i2 = new Integer(975);

 Service service = new Service();
 Call call = (Call) service.createCall();
 call.setTargetEndpointAddress( new java.net.URL(endpoint) );
 call.setUsername("balajidl");
 call.setPassword("somepassword");
 call.setOperationName( "add" );
 call.addParameter( "op1", XMLType.XSD_INT, ParameterMode.IN );
 call.addParameter( "op2", XMLType.XSD_INT, ParameterMode.IN );
 call.setReturnType( XMLType.XSD_INT );

 Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });

 out.println("Got result : " + ret);
} catch (Exception e) {
 System.err.println(e.toString());
}
Raw HTTP without authentication message
POST /axis14/Calculator.jws?wsdl HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8090
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 400

<?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:Body>
 <add soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <op1 xsi:type="xsd:int">5</op1>
 <op2 xsi:type="xsd:int">5</op2>
 </add>
</soapenv:Body>
</soapenv:Envelope>
 




Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Math Quiz 8 + 6 = (Helps stop blog spam)
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

TrackBack to http://radio.javaranch.com/balajidl/addTrackBack.action?entry=1137841305796