Hi,

I am using APACHE SOAP 2.2 for my Java client. I am trying to access the web services written in C#.NET. After compiling my code I get the following exception about content type:

Caught SOAPException (SOAP-ENV:Protocol): Unsupported response content type "text/plain; charset=utf-8", must be: "text/xml". Response was:
System.InvalidOperationException: Request format is invalid: text/xml; charset=utf-8.
   at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.Invoke()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

 

I've also pasted below my code. I'm trying to access a Login function on my SOAP Web Server with 2 parameters, LoginName and Password (both values, "q").

 

import java.io.*;

import java.util.*;

import java.net.*;

import org.w3c.dom.*;

import org.apache.soap.util.xml.*;

import org.apache.soap.*;

import org.apache.soap.encoding.*;

import org.apache.soap.encoding.soapenc.*;

import org.apache.soap.rpc.*;

import org.apache.soap.transport.http.SOAPHTTPConnection;

public class StoragePoint

{

public static void main(String[] args) throws Exception

{

URL url = "">new URL ("http://localhost/soap/SoapUser.asmx/Login");

SOAPMappingRegistry smr = new SOAPMappingRegistry ();

StringDeserializer sd = new StringDeserializer ();

smr.mapTypes (Constants.NS_URI_SOAP_ENC, new QName ("", "Result"), null, null, sd);

// create the transport and set parameters

SOAPHTTPConnection st = new SOAPHTTPConnection();

// build the call.

Call call = new Call ();

call.setSOAPTransport(st);

call.setSOAPMappingRegistry (smr);

call.setTargetObjectURI ("http://tempuri.org/message/");

call.setMethodName("Login");

call.setEncodingStyleURI ("http://schemas.xmlsoap.org/soap/encoding/");

Vector params = new Vector();

params.addElement(new Parameter("LoginName", String.class, "q", null));

params.addElement(new Parameter("Password", String.class, "q", null));

call.setParams(params);

Response resp = null;

try

{

resp = call.invoke (url, "");

}

catch (SOAPException e)

{

System.err.println("Caught SOAPException (" + e.getFaultCode () + "): " + e.getMessage ());

return;

}

// check response

if (resp != null && !resp.generatedFault())

{

Parameter ret = resp.getReturnValue();

Object value = ret.getValue();

System.out.println ("Answer--> " + value);

}

else

{

Fault fault = resp.getFault ();

System.err.println ("Generated fault: ");

System.out.println (" Fault Code = " + fault.getFaultCode());

System.out.println (" Fault String = " + fault.getFaultString());

}

}

}

 

Any help/suggestions is HIGHLY appreciated. I even used SUN's JAXP and I get the same error message.

Thanks in ADVANCE!!

Siddhartha



Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Reply via email to