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

Problem of # sign added by SOAP::Lite in the sent SOAPAction string

Expand Messages
  • Bruno Baguette
    Hello, I have a problem with a SOAP client written in Perl (source at the end). I ve tried both ways (by commenting TRIAL ONE or SECOND TRIAL), and I get
    Message 1 of 2 , Nov 5, 2004
    View Source
    • 0 Attachment
      Hello,

      I have a problem with a SOAP client written in Perl (source at the
      end). I've tried both ways (by commenting TRIAL ONE or SECOND TRIAL),
      and I get exactly the same results.

      When I see the trace of that script, I notice that there is a # sign
      before the method I try to invoque.

      I think that that # sign may be responsible of the SOAP error I get :
      System.Web.Services.Protocols.SoapException: Server did not recognize
      the value of HTTP Header SOAPAction: #GetProperties.

      If I see the trace of the SOAP::Lite module, I see that it send
      #GetProperties instead of GetProperties :
      SOAPAction:
      "http://schemas.dataswitch.be/service/2.7/export/#GetProperties"

      Is there a way to avoid that # sign in the sent SOAPAction by the
      SOAP::Lite module ?

      Thanks _very_ much in advance for your help !

      --
      Bruno BAGUETTE

      ==== CODE ====

      use SOAP::Lite +trace;
      use strict;

      # Skarabee userid/passwd
      my $UserId = "xxx";
      my $Password = "xxx";

      my $PropertiesList;

      sub SOAP::Transport::HTTP::Client::get_basic_credentials { return
      ($UserId => $Password) };

      my $SOAPService = new SOAP::Lite();
      $SOAPService->service('file:./myfile.wsdl');
      $SOAPService->proxy('http://www.HOSTNAME.be/service/v27/export.asmx');
      $SOAPService->on_fault(sub { my($soap, $res) = @_; die ref $res ?
      $res->faultstring : $soap->transport->status, "\n"; });

      # TRIAL ONE
      $PropertiesList = $SOAPService -> GetProperties(Token =>0) -> result();
      print('Results : ['.$PropertiesList.']');

      # SECOND TRIAL
      my $response = $SOAPService
      ->call(SOAP::Data->name('GetProperties')
      ->attr( { xmlns => 'http://www.HOSTNAME.be/service/2.7/export/' } )
      => # Argument(s) listed next
      SOAP::Data->name(Token => 0));
      if ($response->fault)
      {
      printf "A fault (%s) occurred: %s\n", $response->faultcode,
      $response->faultstring;
      }
      else
      {
      print "Resultats : [" . $response->result ."]\n";
      }

      ==== CODE ====
    • Duncan Cameron
      ... The SOAPAction should be specified in your WSDL file as an attribute on the element. If you are calling a dot Net service then you may get
      Message 2 of 2 , Nov 6, 2004
      View Source
      • 0 Attachment
        On 2004-11-05 at 22:55:22 Bruno Baguette wrote:

        >Hello,
        >
        >I have a problem with a SOAP client written in Perl (source at the
        >end). I've tried both ways (by commenting TRIAL ONE or SECOND TRIAL),
        >and I get exactly the same results.
        >
        >When I see the trace of that script, I notice that there is a # sign
        >before the method I try to invoque.
        >
        >I think that that # sign may be responsible of the SOAP error I get :
        >System.Web.Services.Protocols.SoapException: Server did not recognize
        >the value of HTTP Header SOAPAction: #GetProperties.
        >
        >If I see the trace of the SOAP::Lite module, I see that it send
        >#GetProperties instead of GetProperties :
        >SOAPAction:
        >"http://schemas.dataswitch.be/service/2.7/export/#GetProperties"
        >
        >Is there a way to avoid that # sign in the sent SOAPAction by the
        >SOAP::Lite module ?

        The SOAPAction should be specified in your WSDL file as an attribute on
        the <soap:operation> element.

        If you are calling a dot Net service then you may get more success by
        not using the WSDL directly. Simply get the necessary information from
        the WSDL and then use the proxy() and uri() calls on SOAP::Lite. In this
        case you will need to override the on_action method to concatenate with
        '/' the two parameters. Taking your second example and modifying it to
        be something like

        my $s = SOAP::Lite
        ->proxy('http://www.HOSTNAME.be/service/v27/export.asmx')
        ->uri('http://schemas.dataswitch.be/service/2.7/export')
        ->on_action(sub { "$_[0]/$_[1]" })
        ;

        then like you have in that example for calling the service

        ># SECOND TRIAL
        >my $response = $SOAPService
        >->call(SOAP::Data->name('GetProperties')
        >->attr( { xmlns => 'http://www.HOSTNAME.be/service/2.7/export/' } )
        >=> # Argument(s) listed next
        >SOAP::Data->name(Token => 0));
        >if ($response->fault)
        >{
        > printf "A fault (%s) occurred: %s\n", $response->faultcode,
        >$response->faultstring;
        >}
        >else
        >{
        > print "Resultats : [" . $response->result ."]\n";
        >}

        Regards
        Duncan
      Your message has been successfully submitted and would be delivered to recipients shortly.