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

.NET Server/Java client, method params ignored?

Expand Messages
  • derrick_butler
    Hi All - I ve been able to create a simple C# web service using .NET beta 2 with a no param Hello World method, and have been able to call that method from a
    Message 1 of 5 , Apr 1, 2002
      Hi All -

      I've been able to create a simple C# web service using .NET beta 2
      with a no param 'Hello World' method, and have been able to call that
      method from a java client running with Soap 2.2, and get back 'hello
      world' in my java client code. When i add a simple param to 'Hello
      World' however, the param value i pass never reaches the C# method,
      any ideas? Below is code for .Net service, java client, the soap
      request the client generates, and the soap request .NET is saying it
      expects, looks like i need to somehow change the encoding on the
      client?

      Thanks in advance for any info!!

      Derrick


      .NET Web Service method

      [WebMethod]
      public string HelloWorld2(string stName)
      {
      return "Hello World " + stName;
      }

      Java client code that tries to call .NET web service

      URL url = new URL ("http://localhost/DTS/service1.asmx");

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

      Vector params = new Vector();
      params.addElement(new Parameter("stName", String.class, "Fred",
      null));
      call.setParams(params);

      //call.getb
      Response resp = call.invoke
      (url, "http://tempuri.org/HelloWorld2");


      Watching with TCP Tunnel monitor, here is the soap request from java
      client:

      POST /DTS/service1.asmx HTTP/1.0

      Host: localhost

      Content-Type: text/xml; charset=utf-8

      Content-Length: 464

      SOAPAction: "http://tempuri.org/HelloWorld2"



      <?xml version='1.0' encoding='UTF-8'?>

      <SOAP-ENV:Envelope xmlns:SOAP-
      ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema">

      <SOAP-ENV:Body>

      <ns1:HelloWorld2 xmlns:ns1="http://tempuri.org/message" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <NameX xsi:type="xsd:string">Fred</NameX>

      </ns1:HelloWorld2>

      </SOAP-ENV:Body>

      </SOAP-ENV:Envelope>


      However, running the service in .NET debugger, this is the envelope
      it says it expects:

      POST /DTS/Service1.asmx HTTP/1.1
      Host: localhost
      Content-Type: text/xml; charset=utf-8
      Content-Length: length
      SOAPAction: "http://tempuri.org/HelloWorld2"

      <?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>
      <HelloWorld2 xmlns="http://tempuri.org/">
      <stName>string</stName>
      </HelloWorld2>
      </soap:Body>
      </soap:Envelope>
    • Sam Ruby
      To ensure interoperability, make very sure that you get the correct parameter names. Here is a successful example with various data types:
      Message 2 of 5 , Apr 1, 2002
        To ensure interoperability, make very sure that you get the correct
        parameter names.

        Here is a successful example with various data types:

        http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-soap/java/samples/interop/EchoTestClient.java

        Here is the same example using JAX RPC and Apache Axis. You might find it
        simpler and less error prone:

        http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-axis/java/samples/echo/TestClient.java

        - Sam Ruby
      • Chester Chen
        Hi, Sam This is great. Any samples for using .net or VB as Client to test Apache SOAP 2.2 or AXIS server ? Chester ...
        Message 3 of 5 , Apr 1, 2002
          Hi, Sam
          This is great. Any samples for using .net or VB as
          Client to test Apache SOAP 2.2 or AXIS server ?

          Chester


          --- Sam Ruby <rubys@...> wrote:
          > To ensure interoperability, make very sure that you
          > get the correct
          > parameter names.
          >
          > Here is a successful example with various data
          > types:
          >
          >
          >
          http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-soap/java/samples/interop/EchoTestClient.java
          >
          > Here is the same example using JAX RPC and Apache
          > Axis. You might find it
          > simpler and less error prone:
          >
          >
          >
          http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-axis/java/samples/echo/TestClient.java
          >
          > - Sam Ruby
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Yahoo! Greetings - send holiday greetings for Easter, Passover
          http://greetings.yahoo.com/
        • derrick_butler
          Thanks for the links, I went thru the sample code, and did have my param names mismatched in the example I gave. I am still getting my param values dropped
          Message 4 of 5 , Apr 9, 2002
            Thanks for the links, I went thru the sample code, and did have my
            param names mismatched in the example I gave. I am still getting my
            param values 'dropped' before they get to my C# .NET beta 2 web
            service though, any other ideas?

            Again, here's what .NET says it expects for my C# method...

            POST /DTS/Service1.asmx HTTP/1.1
            Host: localhost
            Content-Type: text/xml; charset=utf-8
            Content-Length: length
            SOAPAction: "http://tempuri.org/HelloWorld2"

            <?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>
            <HelloWorld2 xmlns="http://tempuri.org/">
            <NAME>string</NAME>
            </HelloWorld2>
            </soap:Body>
            </soap:Envelope>



            Here is what is being sent from my java client...


            POST /DTS/service1.asmx HTTP/1.0
            Host: localhost
            Content-Type: text/xml; charset=utf-8
            Content-Length: 466
            SOAPAction: "http://tempuri.org/HelloWorld2"

            <?xml version='1.0' encoding='UTF-8'?>
            <SOAP-ENV:Envelope xmlns:SOAP-
            ENV="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/1999/XMLSchema">
            <SOAP-ENV:Body>
            <ns1:HelloWorld2 xmlns:ns1="http://tempuri.org/HelloWorld2" SOAP-
            ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <NAME xsi:type="xsd:string">Fred</NAME>
            </ns1:HelloWorld2>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>


            And here is the java client code...



            URL url = new URL ("http://localhost:8080/DTS/service1.asmx");

            SOAPMappingRegistry smr = new SOAPMappingRegistry ();
            smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName
            ("http://tempuri.org/", "HelloWorld2Result"), null, null, stringDser);

            // 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/HelloWorld2");
            call.setMethodName("HelloWorld2");
            call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

            Vector params = new Vector();
            params.addElement(new Parameter("NAME", String.class, "Fred",
            null));
            call.setParams(params);

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

            Thanks again in advance, looks like an encoding style interop problem?

            Derrick


            --- In soapbuilders@y..., "Sam Ruby" <rubys@u...> wrote:
            > To ensure interoperability, make very sure that you get the correct
            > parameter names.
            >
            > Here is a successful example with various data types:
            >
            > http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-
            soap/java/samples/interop/EchoTestClient.java
            >
            > Here is the same example using JAX RPC and Apache Axis. You might
            find it
            > simpler and less error prone:
            >
            > http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-
            axis/java/samples/echo/TestClient.java
            >
            > - Sam Ruby
          • Simon Fell
            You re sending a section 5 encoded message to an endpoint expecting a doc/literal request, You ll need to either change the .NET end to use section 5 encoding,
            Message 5 of 5 , Apr 9, 2002
              You're sending a section 5 encoded message to an endpoint expecting a
              doc/literal request, You'll need to either change the .NET end to use
              section 5 encoding, or change your Java code to send a doc/literal
              request. [I really wish ASP.NET faulted when it saw an unexpected
              encoding, this has to be the most common interop issue currently]

              Cheers
              Simon
              www.pocketsoap.com

              On Tue, 09 Apr 2002 21:16:22 -0000, in soap you wrote:

              >Thanks for the links, I went thru the sample code, and did have my
              >param names mismatched in the example I gave. I am still getting my
              >param values 'dropped' before they get to my C# .NET beta 2 web
              >service though, any other ideas?
              >
              >Again, here's what .NET says it expects for my C# method...
              >
              >POST /DTS/Service1.asmx HTTP/1.1
              >Host: localhost
              >Content-Type: text/xml; charset=utf-8
              >Content-Length: length
              >SOAPAction: "http://tempuri.org/HelloWorld2"
              >
              ><?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>
              > <HelloWorld2 xmlns="http://tempuri.org/">
              > <NAME>string</NAME>
              > </HelloWorld2>
              > </soap:Body>
              ></soap:Envelope>
              >
              >
              >
              >Here is what is being sent from my java client...
              >
              >
              >POST /DTS/service1.asmx HTTP/1.0
              >Host: localhost
              >Content-Type: text/xml; charset=utf-8
              >Content-Length: 466
              >SOAPAction: "http://tempuri.org/HelloWorld2"
              >
              ><?xml version='1.0' encoding='UTF-8'?>
              ><SOAP-ENV:Envelope xmlns:SOAP-
              >ENV="http://schemas.xmlsoap.org/soap/envelope/"
              >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
              >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
              ><SOAP-ENV:Body>
              ><ns1:HelloWorld2 xmlns:ns1="http://tempuri.org/HelloWorld2" SOAP-
              >ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
              ><NAME xsi:type="xsd:string">Fred</NAME>
              ></ns1:HelloWorld2>
              ></SOAP-ENV:Body>
              ></SOAP-ENV:Envelope>
              >
              >
              >And here is the java client code...
              >
              >
              >
              > URL url = new URL ("http://localhost:8080/DTS/service1.asmx");
              >
              > SOAPMappingRegistry smr = new SOAPMappingRegistry ();
              > smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName
              >("http://tempuri.org/", "HelloWorld2Result"), null, null, stringDser);
              >
              > // 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/HelloWorld2");
              > call.setMethodName("HelloWorld2");
              > call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
              >
              > Vector params = new Vector();
              > params.addElement(new Parameter("NAME", String.class, "Fred",
              >null));
              > call.setParams(params);
              >
              > Response resp = null;
              > try
              > {
              > resp = call.invoke (url, "http://tempuri.org/HelloWorld2");
              > }
              > catch (SOAPException e)
              > {
              > System.err.println("Caught SOAPException (" + e.getFaultCode ()
              >+ "): " + e.getMessage ());
              > return;
              > }
              >
              >Thanks again in advance, looks like an encoding style interop problem?
              >
              >Derrick
              >
              >
              >--- In soapbuilders@y..., "Sam Ruby" <rubys@u...> wrote:
              >> To ensure interoperability, make very sure that you get the correct
              >> parameter names.
              >>
              >> Here is a successful example with various data types:
              >>
              >> http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-
              >soap/java/samples/interop/EchoTestClient.java
              >>
              >> Here is the same example using JAX RPC and Apache Axis. You might
              >find it
              >> simpler and less error prone:
              >>
              >> http://cvs.apache.org/viewcvs.cgi/~checkout~/xml-
              >axis/java/samples/echo/TestClient.java
              >>
              >> - Sam Ruby
              >
              >
              >
              >-----------------------------------------------------------------
              >This group is a forum for builders of SOAP implementations to discuss implementation and interoperability issues. Please stay on-topic.
              >
              >To unsubscribe from this group, send an email to:
              >soapbuilders-unsubscribe@yahoogroups.com
              >
              >
              >
              >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.