You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Siddhartha Mehta <si...@yahoo.com> on 2002/12/07 21:20:30 UTC

Accessing C# Web service from Java Client...

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 &quot;text/plain; charset=utf-8&quot;, must be: &quot;text/xml&quot;. 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

Axis Buggy?

Posted by michel <co...@videotron.ca>.
I've been trying to use Axis for about a week now, and I'm frankly
disappointed in what appears to be a highly unreliable software. I will run
an application twice, and while it runs the second time fine, the first time
it threw an exception. Another application worked fine for a while, now it
doesn't. How does Axis stack up against Wasp or Glue? I'm pretty well fed up
with Axis and am ready to try one of the above.


Thanks for any response!!!


Axis Buggy?

Posted by michel <co...@videotron.ca>.
I've been trying to use Axis for about a week now, and I'm frankly
disappointed in what appears to be a highly unreliable software. I will run
an application twice, and while it runs the second time fine, the first time
it threw an exception. Another application worked fine for a while, now it
doesn't. How does Axis stack up against Wasp or Glue? I'm pretty well fed up
with Axis and am ready to try one of the above.


Thanks for any response!!!


Re: Passing a Class File Content

Posted by Scott Nichol <sn...@scottnichol.com>.
You cannot send binary data as a string.  You should something like
byte[] instead.

Scott Nichol

----- Original Message -----
From: "michel" <co...@videotron.ca>
To: <so...@xml.apache.org>
Sent: Sunday, December 08, 2002 8:11 PM
Subject: Passing a Class File Content


> I'm trying to send the content of a java class file  to a server
through a
> SOAP request (as an XMLType.XSD_STRING");
>  but I'm getting the following error:
>
> "org.xml.sax.SAXParseException: An invalid XML character (Unicode:
0x0) was
> found in the element content of the document"
>
>
>
> Is there some way of encoding the request to avoid the problem?
>
>
>
> Thanks for any response!!
>
>
>
>  /**  sends the content of a class file as a   XMLType.XSD_STRING **/
>   public final String upload(String content,String path) throws
Exception {
>     call.setOperationName(new QName("Admin","upload"));
>     call.setReturnType(XMLType.SOAP_STRING);
>
>
call.addParameter("content",XMLType.XSD_STRING,ParameterMode.PARAM_MODE_
IN);
>     this.response = (String) call.invoke(new Object[]{content});
>     call.removeAllParameters();
>     return response;
>   }
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>


Re: Passing a Class File Content

Posted by Scott Nichol <sn...@scottnichol.com>.
You cannot send binary data as a string.  You should something like
byte[] instead.

Scott Nichol

----- Original Message -----
From: "michel" <co...@videotron.ca>
To: <so...@xml.apache.org>
Sent: Sunday, December 08, 2002 8:11 PM
Subject: Passing a Class File Content


> I'm trying to send the content of a java class file  to a server
through a
> SOAP request (as an XMLType.XSD_STRING");
>  but I'm getting the following error:
>
> "org.xml.sax.SAXParseException: An invalid XML character (Unicode:
0x0) was
> found in the element content of the document"
>
>
>
> Is there some way of encoding the request to avoid the problem?
>
>
>
> Thanks for any response!!
>
>
>
>  /**  sends the content of a class file as a   XMLType.XSD_STRING **/
>   public final String upload(String content,String path) throws
Exception {
>     call.setOperationName(new QName("Admin","upload"));
>     call.setReturnType(XMLType.SOAP_STRING);
>
>
call.addParameter("content",XMLType.XSD_STRING,ParameterMode.PARAM_MODE_
IN);
>     this.response = (String) call.invoke(new Object[]{content});
>     call.removeAllParameters();
>     return response;
>   }
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>
>
>


Passing a Class File Content

Posted by michel <co...@videotron.ca>.
I'm trying to send the content of a java class file  to a server through a
SOAP request (as an XMLType.XSD_STRING");
 but I'm getting the following error:

"org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was
found in the element content of the document"



Is there some way of encoding the request to avoid the problem?



Thanks for any response!!



 /**  sends the content of a class file as a   XMLType.XSD_STRING **/
  public final String upload(String content,String path) throws Exception {
    call.setOperationName(new QName("Admin","upload"));
    call.setReturnType(XMLType.SOAP_STRING);

call.addParameter("content",XMLType.XSD_STRING,ParameterMode.PARAM_MODE_IN);
    this.response = (String) call.invoke(new Object[]{content});
    call.removeAllParameters();
    return response;
  }







Passing a Class File Content

Posted by michel <co...@videotron.ca>.
I'm trying to send the content of a java class file  to a server through a
SOAP request (as an XMLType.XSD_STRING");
 but I'm getting the following error:

"org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was
found in the element content of the document"



Is there some way of encoding the request to avoid the problem?



Thanks for any response!!



 /**  sends the content of a class file as a   XMLType.XSD_STRING **/
  public final String upload(String content,String path) throws Exception {
    call.setOperationName(new QName("Admin","upload"));
    call.setReturnType(XMLType.SOAP_STRING);

call.addParameter("content",XMLType.XSD_STRING,ParameterMode.PARAM_MODE_IN);
    this.response = (String) call.invoke(new Object[]{content});
    call.removeAllParameters();
    return response;
  }







Re: Accessing C# Web service from Java Client...

Posted by Siddhartha Mehta <si...@yahoo.com>.
Oh.. that was a silly mistake. Got it working though!!
 Siddhartha Mehta <si...@yahoo.com> wrote:
Yes, that was an error with the SOAPAction. I use MimeHeaders to set the header with SOAPAction and its working for me. Now when I send the login name and password, I get the string in return with the session key. But I am not able to just retrieve the session key from the response. I've pasted below the response and the code I am using to retrieve. The iterator does not have any value in it. 
*********************************************************************************************** 
SOAP Request 
<?xml version="1.0" encoding="UTF-8"?> 
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> 
<soap-env:Header/><soap-env:Body><Login xmlns="http://storagepoint.net/soap/"> 
<LoginName>q</LoginName> 
<Password>q</Password></Login> 
</soap-env:Body> 
</soap-env:Envelope> 
************************************************************************************************* 
*************************************************************************************************
SOAP Response 
<?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/X
LSchema"><soap:Body><LoginResponse xmlns="http://storagepoint.net/soap/"><Login
esult>402CE00E-DBAC-4BDD-9EB3-FEE3A6575CAD</LoginResult></LoginResponse></soap:
ody></soap:Envelope>


*************************************************************************************************

My function... 
SOAPPart soapPartResponse = reply.getSOAPPart();
SOAPEnvelope soapEnvelopeResponse = soapPartResponse.getEnvelope();
SOAPBody soapBodyResponse = soapEnvelopeResponse.getBody();
         
Name bodyName1 = soapEnvelope.createName("LoginResult");
Iterator iterator = soapBodyResponse.getChildElements(bodyName1);
SOAPElement soapBodyElement = (SOAPElement)iterator.next(); 
************************************************************************************************* 
I checked iterator.hasNext() and it returns false. Please let me know how do I get the value from the response. 
Thanks, 
Siddhartha 
 Scott Nichol <sn...@scottnichol.com> wrote: 
Microsoft web services use SOAPAction to determine the method to
execute. Your call.invoke is specifying an empty string. The WSDL for
the service will show you the SOAPAction. 
Also, have you written the .NET web service to use rpc/encoded? Apache
SOAP always sends rpc/encoded messages. You do this with the
SoapRpcService attribute, e.g. 
[SoapRpcService, WebService(Namespace="urn:echo-test-1")]
public class EchoTest1Service : System.Web.Services.WebService {
... 
Scott Nichol



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


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

Re: Accessing C# Web service from Java Client...

Posted by Siddhartha Mehta <si...@yahoo.com>.
Oh.. that was a silly mistake. Got it working though!!
 Siddhartha Mehta <si...@yahoo.com> wrote:
Yes, that was an error with the SOAPAction. I use MimeHeaders to set the header with SOAPAction and its working for me. Now when I send the login name and password, I get the string in return with the session key. But I am not able to just retrieve the session key from the response. I've pasted below the response and the code I am using to retrieve. The iterator does not have any value in it. 
*********************************************************************************************** 
SOAP Request 
<?xml version="1.0" encoding="UTF-8"?> 
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> 
<soap-env:Header/><soap-env:Body><Login xmlns="http://storagepoint.net/soap/"> 
<LoginName>q</LoginName> 
<Password>q</Password></Login> 
</soap-env:Body> 
</soap-env:Envelope> 
************************************************************************************************* 
*************************************************************************************************
SOAP Response 
<?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/X
LSchema"><soap:Body><LoginResponse xmlns="http://storagepoint.net/soap/"><Login
esult>402CE00E-DBAC-4BDD-9EB3-FEE3A6575CAD</LoginResult></LoginResponse></soap:
ody></soap:Envelope>


*************************************************************************************************

My function... 
SOAPPart soapPartResponse = reply.getSOAPPart();
SOAPEnvelope soapEnvelopeResponse = soapPartResponse.getEnvelope();
SOAPBody soapBodyResponse = soapEnvelopeResponse.getBody();
         
Name bodyName1 = soapEnvelope.createName("LoginResult");
Iterator iterator = soapBodyResponse.getChildElements(bodyName1);
SOAPElement soapBodyElement = (SOAPElement)iterator.next(); 
************************************************************************************************* 
I checked iterator.hasNext() and it returns false. Please let me know how do I get the value from the response. 
Thanks, 
Siddhartha 
 Scott Nichol <sn...@scottnichol.com> wrote: 
Microsoft web services use SOAPAction to determine the method to
execute. Your call.invoke is specifying an empty string. The WSDL for
the service will show you the SOAPAction. 
Also, have you written the .NET web service to use rpc/encoded? Apache
SOAP always sends rpc/encoded messages. You do this with the
SoapRpcService attribute, e.g. 
[SoapRpcService, WebService(Namespace="urn:echo-test-1")]
public class EchoTest1Service : System.Web.Services.WebService {
... 
Scott Nichol



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


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

Re: Accessing C# Web service from Java Client...

Posted by Siddhartha Mehta <si...@yahoo.com>.
Yes, that was an error with the SOAPAction. I use MimeHeaders to set the header with SOAPAction and its working for me. Now when I send the login name and password, I get the string in return with the session key. But I am not able to just retrieve the session key from the response. I've pasted below the response and the code I am using to retrieve. The iterator does not have any value in it.
***********************************************************************************************
SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/><soap-env:Body><Login xmlns="http://storagepoint.net/soap/">
<LoginName>q</LoginName>
<Password>q</Password></Login>
</soap-env:Body>
</soap-env:Envelope>
*************************************************************************************************
*************************************************************************************************
SOAP Response
<?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/X
LSchema"><soap:Body><LoginResponse xmlns="http://storagepoint.net/soap/"><Login
esult>402CE00E-DBAC-4BDD-9EB3-FEE3A6575CAD</LoginResult></LoginResponse></soap:
ody></soap:Envelope>


*************************************************************************************************

My function...
SOAPPart soapPartResponse = reply.getSOAPPart();
SOAPEnvelope soapEnvelopeResponse = soapPartResponse.getEnvelope();
SOAPBody soapBodyResponse = soapEnvelopeResponse.getBody();
         
Name bodyName1 = soapEnvelope.createName("LoginResult");
Iterator iterator = soapBodyResponse.getChildElements(bodyName1);
SOAPElement soapBodyElement = (SOAPElement)iterator.next();
*************************************************************************************************
I checked iterator.hasNext() and it returns false. Please let me know how do I get the value from the response.
Thanks,
Siddhartha
 Scott Nichol <sn...@scottnichol.com> wrote:
Microsoft web services use SOAPAction to determine the method to
execute. Your call.invoke is specifying an empty string. The WSDL for
the service will show you the SOAPAction.
Also, have you written the .NET web service to use rpc/encoded? Apache
SOAP always sends rpc/encoded messages. You do this with the
SoapRpcService attribute, e.g.
[SoapRpcService, WebService(Namespace="urn:echo-test-1")]
public class EchoTest1Service : System.Web.Services.WebService {
...
Scott Nichol



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

Re: Accessing C# Web service from Java Client...

Posted by Siddhartha Mehta <si...@yahoo.com>.
Yes, that was an error with the SOAPAction. I use MimeHeaders to set the header with SOAPAction and its working for me. Now when I send the login name and password, I get the string in return with the session key. But I am not able to just retrieve the session key from the response. I've pasted below the response and the code I am using to retrieve. The iterator does not have any value in it.
***********************************************************************************************
SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/><soap-env:Body><Login xmlns="http://storagepoint.net/soap/">
<LoginName>q</LoginName>
<Password>q</Password></Login>
</soap-env:Body>
</soap-env:Envelope>
*************************************************************************************************
*************************************************************************************************
SOAP Response
<?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/X
LSchema"><soap:Body><LoginResponse xmlns="http://storagepoint.net/soap/"><Login
esult>402CE00E-DBAC-4BDD-9EB3-FEE3A6575CAD</LoginResult></LoginResponse></soap:
ody></soap:Envelope>


*************************************************************************************************

My function...
SOAPPart soapPartResponse = reply.getSOAPPart();
SOAPEnvelope soapEnvelopeResponse = soapPartResponse.getEnvelope();
SOAPBody soapBodyResponse = soapEnvelopeResponse.getBody();
         
Name bodyName1 = soapEnvelope.createName("LoginResult");
Iterator iterator = soapBodyResponse.getChildElements(bodyName1);
SOAPElement soapBodyElement = (SOAPElement)iterator.next();
*************************************************************************************************
I checked iterator.hasNext() and it returns false. Please let me know how do I get the value from the response.
Thanks,
Siddhartha
 Scott Nichol <sn...@scottnichol.com> wrote:
Microsoft web services use SOAPAction to determine the method to
execute. Your call.invoke is specifying an empty string. The WSDL for
the service will show you the SOAPAction.
Also, have you written the .NET web service to use rpc/encoded? Apache
SOAP always sends rpc/encoded messages. You do this with the
SoapRpcService attribute, e.g.
[SoapRpcService, WebService(Namespace="urn:echo-test-1")]
public class EchoTest1Service : System.Web.Services.WebService {
...
Scott Nichol



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

Re: Accessing C# Web service from Java Client...

Posted by Scott Nichol <sn...@scottnichol.com>.
Microsoft web services use SOAPAction to determine the method to
execute.  Your call.invoke is specifying an empty string.  The WSDL for
the service will show you the SOAPAction.

Also, have you written the .NET web service to use rpc/encoded?  Apache
SOAP always sends rpc/encoded messages.  You do this with the
SoapRpcService attribute, e.g.

 [SoapRpcService, WebService(Namespace="urn:echo-test-1")]
 public class EchoTest1Service : System.Web.Services.WebService {
 ...

Scott Nichol

----- Original Message -----
From: "Siddhartha Mehta" <si...@yahoo.com>
To: <so...@xml.apache.org>
Sent: Saturday, December 07, 2002 3:20 PM
Subject: Accessing C# Web service from Java Client...


>
> 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 &quot;text/plain; charset=utf-8&quot;, must be:
&quot;text/xml&quot;. 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


Re: Accessing C# Web service from Java Client...

Posted by Scott Nichol <sn...@scottnichol.com>.
Microsoft web services use SOAPAction to determine the method to
execute.  Your call.invoke is specifying an empty string.  The WSDL for
the service will show you the SOAPAction.

Also, have you written the .NET web service to use rpc/encoded?  Apache
SOAP always sends rpc/encoded messages.  You do this with the
SoapRpcService attribute, e.g.

 [SoapRpcService, WebService(Namespace="urn:echo-test-1")]
 public class EchoTest1Service : System.Web.Services.WebService {
 ...

Scott Nichol

----- Original Message -----
From: "Siddhartha Mehta" <si...@yahoo.com>
To: <so...@xml.apache.org>
Sent: Saturday, December 07, 2002 3:20 PM
Subject: Accessing C# Web service from Java Client...


>
> 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 &quot;text/plain; charset=utf-8&quot;, must be:
&quot;text/xml&quot;. 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