Hi,
I am trying to create a
java client using Apache Axis to call a .net web service.Web service is very simple.m using .net 2.0 to build the web service.i used tcp mon to see the
soap msg generated and generated msg was
POST /WebSite3/Service.asmx 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:8089
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 340
<?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>
<HelloWorld soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</soapenv:Body>
</soapenv:Envelope>
and the result was
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/8.0.0.0
Date: Fri, 27 Mar 2009 20:08:05 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Content-Length: 1005
Connection: Close
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Following is the expected SOAP 1.1 request and response.
POST /WebSite3/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://mywebservice.org/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://mywebservice.org/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://mywebservice.org/">
<HelloWorldResult>
string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
----here is the java code---------
package classes;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import com.ibm.wsdl.extensions.soap.SOAPConstants;
import javax.xml.rpc.ParameterMode;
public class NHLServiceClient {
public static void main(String [] args) throws Exception {
Service service = new Service();
Call call = (Call)service.createCall();
String endpoint = "http://localhost:8089/WebSite3/Service.asmx";
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("HelloWorld");
SOAPConstants soapConstants=new SOAPConstants();
String position = (String)call.invoke( new Object [] { } );
System.out.println("Got result : " + position);
}
}
------ java code ends----
------Here is the code for .Net web service------
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://mywebservice.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
---- code ends-------
Please help me guys.. m desprate.. have been trying to get this code running for the past 4 days
Thanks in advance
Moiz