Loading ...
Sorry, an error occurred while loading the content.

Please help! SoapRpcMethod in .NET & encoding style in Apache

Expand Messages
  • yuanxingz
    Hello, I am new to this area. Hope can get your help. I am writing an JAVA client to call an .NET VB server. I use Apache SOAP v2.3 and Microsoft .NET
    Message 1 of 2 , Jul 22, 2003
    • 0 Attachment
      Hello,

      I am new to this area. Hope can get your help. I am writing an JAVA
      client to call an .NET VB server. I use Apache SOAP v2.3 and
      Microsoft .NET Framework 1.0.

      I get two different errors when invoke the call depends on whether or
      not I set 'SoapRpcMethod' in my VB server program:

      First error like:
      Generated fault:
      Fault Code = soap:Client
      Fault String = Server was unable to read request. --> There is an
      error in XML document (4, 2). --> <addNumbers
      xmlns='http://www.denisebl.com/addNumbers'> was not expected.

      In here, my VB server program is:

      Imports System.Web.Services
      Imports System.Web.Services.Protocols
      Imports System.Web.Services.Description
      Imports System

      <WebService(Namespace:="http://www.denisebl.com/")> _
      Public Class Hello2
      Inherits System.Web.Services.WebService
      <WebMethod(),System.Web.Services.Protocols.SoapRpcMethod() > _
      Public Function addNumbers(ByVal NumberOne As Double, ByVal
      NumberTwo As Double) As Double
      addNumbers = NumberOne + NumberTwo
      End Function
      End Class


      If I do not include SoapRpcMethod in my VB program,
      <WebMethod()> _
      Public Function addNumbers(ByVal NumberOne As Double, ByVal
      NumberTwo As Double) As Double
      addNumbers = NumberOne + NumberTwo
      End Function

      the error I get is:
      Caught SOAPException (SOAP-ENV:Client): No Deserializer found to
      deserialize a 'http://www.denisebl.com/:addNumbersResult'
      using encoding style 'null'.



      My JAVA client is the following:

      Client code:
      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;
      import java.lang.Object;

      public class testClient
      {
      public static void main(String[] args) throws Exception
      {
      URL url = new URL (args[0]);

      SOAPMappingRegistry smr = new SOAPMappingRegistry ();
      StringDeserializer sd = new StringDeserializer ();
      smr.mapTypes (Constants.NS_URI_SOAP_ENC,new QName
      ("http://www.denisebl.com", "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://www.denisebl.com/addNumbers");
      call.setMethodName("addNumbers");
      call.setEncodingStyleURI
      ("http://schemas.xmlsoap.org/soap/encoding/");

      Vector params = new Vector();
      params.addElement(new Parameter("NumberOne",
      Double.class, "10", null));
      params.addElement(new Parameter("NumberTwo",
      Double.class, "25", null));
      call.setParams(params);

      System.out.println("\n\nCalling the VB Server to say add,
      result=\n\n");

      Response resp = null;
      try
      {
      resp = call.invoke (url, "http://www.denisebl.com/addNumbers");
      }
      catch (SOAPException e)
      {
      System.err.println("Caught SOAPException (" +
      e.getFaultCode () + "): " +
      e.getMessage ());
      return;
      }

      if (resp == null)
      {
      System.out.println("Response was null");
      }

      // 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
      ());
      }
      }
      }

      I have read quite a lot discussions about the interoperability probem
      between Apache and .NET, and I think I have followed all the advice,
      but still can't get a clue why my program does not work.

      Many thanks for any of your suggestion!!
    • Sue Chauner
      yuanxingz, A quick guess might be that when you are adding a new param to your vector, the last variable should be Constants.NS_URI_SOAP_ENC, instead of null.
      Message 2 of 2 , Jul 22, 2003
      • 0 Attachment
        yuanxingz,
        A quick guess might be that when you are adding a new param to your vector, the last
        variable should be Constants.NS_URI_SOAP_ENC, instead of null.
        params.addElement(new Parameter("NumberOne", > Double.class, "10",
        Constants.NS_URI_SOAP_ENC ));
        I also found that I needed to add mappings to my deployment descriptor when a .NET
        client was attempting to hit my web service.
        Hope this helps.


        --- yuanxingz <yuanxingz@...> wrote:
        > Hello,
        >
        > I am new to this area. Hope can get your help. I am writing an JAVA
        > client to call an .NET VB server. I use Apache SOAP v2.3 and
        > Microsoft .NET Framework 1.0.
        >
        > I get two different errors when invoke the call depends on whether or
        > not I set 'SoapRpcMethod' in my VB server program:
        >
        > First error like:
        > Generated fault:
        > Fault Code = soap:Client
        > Fault String = Server was unable to read request. --> There is an
        > error in XML document (4, 2). --> <addNumbers
        > xmlns='http://www.denisebl.com/addNumbers'> was not expected.
        >
        > In here, my VB server program is:
        >
        > Imports System.Web.Services
        > Imports System.Web.Services.Protocols
        > Imports System.Web.Services.Description
        > Imports System
        >
        > <WebService(Namespace:="http://www.denisebl.com/")> _
        > Public Class Hello2
        > Inherits System.Web.Services.WebService
        > <WebMethod(),System.Web.Services.Protocols.SoapRpcMethod() > _
        > Public Function addNumbers(ByVal NumberOne As Double, ByVal
        > NumberTwo As Double) As Double
        > addNumbers = NumberOne + NumberTwo
        > End Function
        > End Class
        >
        >
        > If I do not include SoapRpcMethod in my VB program,
        > <WebMethod()> _
        > Public Function addNumbers(ByVal NumberOne As Double, ByVal
        > NumberTwo As Double) As Double
        > addNumbers = NumberOne + NumberTwo
        > End Function
        >
        > the error I get is:
        > Caught SOAPException (SOAP-ENV:Client): No Deserializer found to
        > deserialize a 'http://www.denisebl.com/:addNumbersResult'
        > using encoding style 'null'.
        >
        >
        >
        > My JAVA client is the following:
        >
        > Client code:
        > 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;
        > import java.lang.Object;
        >
        > public class testClient
        > {
        > public static void main(String[] args) throws Exception
        > {
        > URL url = new URL (args[0]);
        >
        > SOAPMappingRegistry smr = new SOAPMappingRegistry ();
        > StringDeserializer sd = new StringDeserializer ();
        > smr.mapTypes (Constants.NS_URI_SOAP_ENC,new QName
        > ("http://www.denisebl.com", "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://www.denisebl.com/addNumbers");
        > call.setMethodName("addNumbers");
        > call.setEncodingStyleURI
        > ("http://schemas.xmlsoap.org/soap/encoding/");
        >
        > Vector params = new Vector();
        > params.addElement(new Parameter("NumberOne",
        > Double.class, "10", null));
        > params.addElement(new Parameter("NumberTwo",
        > Double.class, "25", null));
        > call.setParams(params);
        >
        > System.out.println("\n\nCalling the VB Server to say add,
        > result=\n\n");
        >
        > Response resp = null;
        > try
        > {
        > resp = call.invoke (url, "http://www.denisebl.com/addNumbers");
        > }
        > catch (SOAPException e)
        > {
        > System.err.println("Caught SOAPException (" +
        > e.getFaultCode () + "): " +
        > e.getMessage ());
        > return;
        > }
        >
        > if (resp == null)
        > {
        > System.out.println("Response was null");
        > }
        >
        > // 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
        > ());
        > }
        > }
        > }
        >
        > I have read quite a lot discussions about the interoperability probem
        > between Apache and .NET, and I think I have followed all the advice,
        > but still can't get a clue why my program does not work.
        >
        > Many thanks for any of your suggestion!!
        >
        >


        __________________________________
        Do you Yahoo!?
        Yahoo! SiteBuilder - Free, easy-to-use web site design software
        http://sitebuilder.yahoo.com
      Your message has been successfully submitted and would be delivered to recipients shortly.