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

Re: Passing parameter from SOAP::Lite client to .Net server.

Expand Messages
  • mkovalchuk
    Just wanted to give you guys an update on the problem. As it turns out, the problem is not in the actual parameters, but rather in namespace. // .NET code
    Message 1 of 5 , May 1, 2003
    • 0 Attachment
      Just wanted to give you guys an update on the problem.
      As it turns out, the problem is not in the actual parameters, but
      rather in namespace.
      // .NET code
      [WebService(Namespace="http://xyz.com/")]

      Note that there's a "/" at the end.

      # perl
      my $method=SOAP::Data->name("Test")
      ->uri("http://xyz.com/")
      ->prefix("");
      my $samples = SOAP::Data ->name('x' => 11)
      ->type('int');
      my $result = $soap->call($method =>($param));

      If I use exactly the same namespace (with "/" at the end) I get
      soap:Client, System.Web.Services.Protocols.SoapException: Server did
      not recognize the value of HTTP Header SOAPAction:
      http://sig.com//Test.
      (note two slashes).

      If I remove the slash in the perl code (uri("http://xyz.com")), this
      does get to the correct service, but since the namespace is
      different, the parameters are not mapped.

      For now, I got rid of the slash at the end of the namespace in
      my .Net code.
      Does anyone know a better way to handle this problem?

      Thanks.

      Michael


      --- In soaplite@yahoogroups.com, "Michael Kovalchuk"
      <mkovalchuk@h...> wrote:
      >
      > I've already tried specifying the type, getting the same results.
      > Actually, I've removed it after studying an xml message generated
      by a .Net
      > client, that one did not have the types specified.
      >
      > Michael.
      >
      >
      > >From: Sadanand Kalasabail <sade_bhat@y...>
      > >To: mkovalchuk <mkovalchuk@h...>, soaplite@yahoogroups.com
      > >Subject: Re: [soaplite] Passing parameter from SOAP::Lite client
      to .Net
      > >server.
      > >Date: Tue, 22 Apr 2003 17:48:34 -0700 (PDT)
      > >
      > >Add a type in the data.
      > >
      > > my $param = SOAP::Data ->name('x' =>
      > >25)->type('xsi:string');
      > >
      > >or if its number define it accordingly.
      > >
      > >
      > >
      > >--- mkovalchuk <mkovalchuk@h...> wrote:
      > > > I'm writing a perl client connecting to a .Net web
      > > > service. It seems
      > > > that I can successfully get to the correct web
      > > > service api, but, the
      > > > problem is that the parameters are not initialized
      > > > to correct values
      > > > (the ones i'm passing), they are 0 for numbers,
      > > > nulls for strings etc.
      > > > Was just wondering if anyone can share the
      > > > experties.
      > > > ---------------------
      > > > Here's my test .Net API api:
      > > > [WebService(Namespace="http://xyz.com/")]
      > > > public class Y : System.Web.Services.WebService
      > > > {
      > > > ...
      > > > [WebMethod]
      > > > public string Test(int x)
      > > > {
      > > > string result = "123 " + x.ToString() ;
      > > > return result ;
      > > > }
      > > > ...
      > > > }
      > > > -------------------
      > > > the perl code:
      > > > #!perl -w
      > > >
      > > > #use SOAP::Lite;
      > > > use SOAP::Lite
      > > >
      > >
      (+trace=>"all",soapversion=>'1.1',envprefix=>'soap',xmlschema=>'2001',
      > > > autotype=>0);
      > > >
      > > > my $soap = SOAP::Lite
      > > > -> uri('http://xyz.com')
      > > > -> proxy('http://xyz/x.asmx')
      > > > -> on_action(sub{sprintf '%s/%s', @_ });
      > > >
      > > > my $param = SOAP::Data ->name('x' => 25);
      > > >
      > > > my $result = $soap->Test($param);
      > > >
      > > > unless ($result->fault) {
      > > > print $result->result;
      > > > } else {
      > > > print join ', ',
      > > > $result->faultcode,
      > > > $result->faultstring;
      > > > }
      > > > -----------------------------------------
      > > > This executes (I can catch it on a breakpoint in my
      > > > .Net function
      > > > (but x is not initialized). - 123 0 is returned.
      > > > ------------------------------------
      > > > Trace results:
      > > > Req:
      > > > <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      > > >
      > > >
      > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      > > > xmlns:SOAP-
      > > > ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      > > >
      > >soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      > > >
      > > >
      >
      >xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><na
      m
      > > > esp1:Test
      > > >
      >
      >xmlns:namesp1="http://xyz.com"><x>25</x></namesp1:Test></soap:Body></
      s
      > > > oap:Envelope>
      > > > --------------------------------
      > > > Resp:
      > > > <?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><TestResponse
      > > >
      > > > xmlns="http://xyz.com/"><TestResult>123
      > > >
      > >0</TestResult></TestResponse></soap:Body></soap:Envelope>
    • Randy J. Ray
      ... You can specify an on_action handler when you create the client object. This is responsible for creating the string that will go into the SOAPAction
      Message 2 of 5 , May 1, 2003
      • 0 Attachment
        > If I use exactly the same namespace (with "/" at the end) I get
        > soap:Client, System.Web.Services.Protocols.SoapException: Server did
        > not recognize the value of HTTP Header SOAPAction:
        > http://sig.com//Test.
        > (note two slashes).
        >
        > If I remove the slash in the perl code (uri("http://xyz.com")), this
        > does get to the correct service, but since the namespace is
        > different, the parameters are not mapped.

        You can specify an on_action handler when you create the client object. This
        is responsible for creating the string that will go into the SOAPAction
        header. When the on_action() callback is invoked, it is passed two arguments,
        URI and METHOD, in that order.

        So, in your case, this would probably work:

        my $SOAP = SOAP::Lite->new
        [ ... ]
        ->on_action(sub { join('', @_) })
        [ ... ];

        In your code, you were inserting a / between URI and METHOD in the on_action
        block.

        Randy
        --
        rjray@... http://www.rjray.org http://www.svsm.org

        Any spammers auto-extracting addresses from this message will definitely want
        to include uce@... and report@...
      Your message has been successfully submitted and would be delivered to recipients shortly.