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

Re: Calling a web service - please help

Expand Messages
  • soapnewby
    Duncan, When using trace, I am getting a Soap error related to SoapAction. Do you think you could possibly look at the code below in case you see something
    Message 1 of 10 , Jun 30, 2002
    • 0 Attachment
      Duncan,

      When using trace, I am getting a Soap error related to SoapAction.
      Do you think you could possibly look at the code below in case you
      see something wrong with it? I don't understand why it doesn't like
      this SoapAction... I double-checked and namespace and types look
      OK ... Please help if you can. Thanks SO MUCH!!!
      Lana


      Here is my Perl code:
      =====================================
      my $soap = SOAP::Lite
      ->uri('http://net.trustnet.com/ScorecardService3')
      ->proxy
      ('http://net.trustnet.com/ScorecardService3/ScorecardGenerator.asmx')
      ->on_action(sub {join('/', @_)});

      my $method = SOAP::Data->attr({xmlns
      => 'http://net.trustnet.com/ScorecardService3'}, 'AddItem');

      my $r = $soap->call($method,
      SOAP::Data->name('vchScript' => 'xx')->type('string'),
      SOAP::Data->name('dtLastRan' => '06/30/2002')->type('string'),
      SOAP::Data->name('chSuccessFail' => 's')->type('string'),
      SOAP::Data->name('vchAttempted' => 'a')->type('string'),
      SOAP::Data->name('vchFailed' => 'a')->type('string'),
      SOAP::Data->name('vchErrorMsg' => 'a')->type('string'),
      SOAP::Data->name('iCategory' => 3)->type('int'));

      ========================================

      Here is what the trace error message says:
      ========================================

      SOAP::Transport::HTTP::Client::send_receive: POST
      http://net.trustnet.com/Scorec
      ardService3/ScorecardGenerator.asmx
      Content-Length: 812
      Content-Type: text/xml
      SOAPAction: http://net.trustnet.com/ScorecardService3/

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-
      ENC="http://
      schemas.xmlsoap.org/soap/encoding/" SOAP-
      ENV:encodingStyle="http://schemas.xmlso
      ap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-
      instance" xml
      ns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3
      .org/1999/XMLSchema"><SOAP-ENV:Body><c-gensym5
      xmlns="http://net.trustnet.com/Sc
      orecardService3"><vchScript
      xsi:type="xsd:string">xx</vchScript><dtLastRan xsi:t
      ype="xsd:string">06/30/2002</dtLastRan><chSuccessFail
      xsi:type="xsd:string">s</c
      hSuccessFail><vchAttempted
      xsi:type="xsd:string">a</vchAttempted><vchFailed xsi:
      type="xsd:string">a</vchFailed><vchErrorMsg
      xsi:type="xsd:string">a</vchErrorMsg
      ><iCategory xsi:type="xsd:int">3</iCategory></c-gensym5></SOAP-
      ENV:Body></SOAP-E
      NV:Envelope>
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 (Internal
      Server Error
      ) Internal Server Error.
      Cache-Control: private
      Date: Sun, 30 Jun 2002 19:40:27 GMT
      Server: Microsoft-IIS/5.0
      Content-Length: 682
      Content-Type: text/xml; charset=utf-8
      Client-Date: Sun, 30 Jun 2002 19:41:29 GMT
      Client-Peer: 172.31.129.175:80

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>System.Web.Services.Protocols.SoapException:
      Server did not recognize the value of HTTP Header SOAPAction:
      http://net.trustnet.com/ScorecardService3/.
      at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
      at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type
      type, Http
      Context context, HttpRequest request, HttpResponse response,
      Boolean& abortP
      rocessing)</faultstring>
      <detail />
      </soap:Fault>
      </soap:Body>
      </soap:Envelope>

      ========================================

      So it doesn't like something about SOAPAction. Here is my
      wsdl file:

      ========================================
      <?xml version="1.0" encoding="utf-8" ?>
      - <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:s="http://www.w3.org/2001/XMLSchema"
      xmlns:s0="http://net.trustnet.com/ScorecardService3/"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
      xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
      targetNamespace="http://net.trustnet.com/ScorecardService3/"
      xmlns="http://schemas.xmlsoap.org/wsdl/">
      - <types>
      - <s:schema elementFormDefault="qualified"
      targetNamespace="http://net.trustnet.com/ScorecardService3/">
      - <s:element name="AddItem">
      - <s:complexType>
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="vchScript"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="dtLastRan"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="chSuccessFail"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="vchAttempted"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="vchFailed"
      type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="vchErrorMsg"
      type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="iCategory"
      type="s:int" />
      </s:sequence>
      </s:complexType>
      </s:element>
      - <s:element name="AddItemResponse">
      <s:complexType />
      </s:element>
      </s:schema>
      </types>
      - <message name="AddItemSoapIn">
      <part name="parameters" element="s0:AddItem" />
      </message>
      - <message name="AddItemSoapOut">
      <part name="parameters" element="s0:AddItemResponse" />
      </message>
      - <message name="AddItemHttpGetIn">
      <part name="vchScript" type="s:string" />
      <part name="dtLastRan" type="s:string" />
      <part name="chSuccessFail" type="s:string" />
      <part name="vchAttempted" type="s:string" />
      <part name="vchFailed" type="s:string" />
      <part name="vchErrorMsg" type="s:string" />
      <part name="iCategory" type="s:string" />
      </message>
      <message name="AddItemHttpGetOut" />
      - <message name="AddItemHttpPostIn">
      <part name="vchScript" type="s:string" />
      <part name="dtLastRan" type="s:string" />
      <part name="chSuccessFail" type="s:string" />
      <part name="vchAttempted" type="s:string" />
      <part name="vchFailed" type="s:string" />
      <part name="vchErrorMsg" type="s:string" />
      <part name="iCategory" type="s:string" />
      </message>
      <message name="AddItemHttpPostOut" />
      - <portType name="ScorecardGeneratorSoap">
      - <operation name="AddItem">
      <input message="s0:AddItemSoapIn" />
      <output message="s0:AddItemSoapOut" />
      </operation>
      </portType>
      - <portType name="ScorecardGeneratorHttpGet">
      - <operation name="AddItem">
      <input message="s0:AddItemHttpGetIn" />
      <output message="s0:AddItemHttpGetOut" />
      </operation>
      </portType>
      - <portType name="ScorecardGeneratorHttpPost">
      - <operation name="AddItem">
      <input message="s0:AddItemHttpPostIn" />
      <output message="s0:AddItemHttpPostOut" />
      </operation>
      </portType>
      - <binding name="ScorecardGeneratorSoap"
      type="s0:ScorecardGeneratorSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
      style="document" />
      - <operation name="AddItem">
      <soap:operation
      soapAction="http://net.trustnet.com/ScorecardService3/AddItem"
      style="document" />
      - <input>
      <soap:body use="literal" />
      </input>
      - <output>
      <soap:body use="literal" />
      </output>
      </operation>
      </binding>
      - <binding name="ScorecardGeneratorHttpGet"
      type="s0:ScorecardGeneratorHttpGet">
      <http:binding verb="GET" />
      - <operation name="AddItem">
      <http:operation location="/AddItem" />
      - <input>
      <http:urlEncoded />
      </input>
      <output />
      </operation>
      </binding>
      - <binding name="ScorecardGeneratorHttpPost"
      type="s0:ScorecardGeneratorHttpPost">
      <http:binding verb="POST" />
      - <operation name="AddItem">
      <http:operation location="/AddItem" />
      - <input>
      <mime:content type="application/x-www-form-urlencoded" />
      </input>
      <output />
      </operation>
      </binding>
      - <service name="ScorecardGenerator">
      - <port name="ScorecardGeneratorSoap"
      binding="s0:ScorecardGeneratorSoap">
      <soap:address
      location="http://net.trustnet.com/ScorecardService3/ScorecardGenerator
      .asmx" />
      </port>
      - <port name="ScorecardGeneratorHttpGet"
      binding="s0:ScorecardGeneratorHttpGet">
      <http:address
      location="http://net.trustnet.com/ScorecardService3/ScorecardGenerator
      .asmx" />
      </port>
      - <port name="ScorecardGeneratorHttpPost"
      binding="s0:ScorecardGeneratorHttpPost">
      <http:address
      location="http://net.trustnet.com/ScorecardService3/ScorecardGenerator
      .asmx" />
      </port>
      </service>
      </definitions>
      =========================================================
    • rjray@blackperl.com
      It looks like your choice to create the SOAPAction header with the following callback: on_action(sub {join( / , @_)}) is producing a value that the server
      Message 2 of 10 , Jun 30, 2002
      • 0 Attachment
        It looks like your choice to create the SOAPAction header with the following
        callback:

        on_action(sub {join('/', @_)})

        is producing a value that the server doesn't like.

        Setting SOAPAction *should* be a lot simpler than most non-Perl servers make
        it out to be. Most of the behavior I've seen is totally arbitrary-- there are
        few rules regarding SOAPAction in the SOAP spec itself. There's almost as much
        written in the WSDL spec as there is in the core SOAP spec.

        Try not using that callback (let the default behavior have a go at it).
        Otherwise, if this is based on a WSDL spec, look to see what the server is
        expecting as a SOAPAction for the given operation.

        Randy
        --
        """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        Randy J. Ray rjray@...
        Campbell, CA rjray@...
        <A HREF="http://www.svsm.org">Silicon Valley Scale Modelers</A>
      • soapnewby
        ... The .wsdl file says When I try this simpler version of
        Message 3 of 10 , Jul 1, 2002
        • 0 Attachment
          --- In soaplite@y..., rjray@b... wrote:
          >... look to see what the server is
          > expecting as a SOAPAction for the given operation.

          The .wsdl file says
          <soap:operation
          soapAction="http://net.trustnet.com/ScorecardService3/AddItem"
          style="document" />

          When I try this simpler version of the code:

          SOAP::Lite
          -> uri('http://net.trustnet.com/ScorecardService3/')
          -> proxy
          ('http://net.trustnet.com/ScorecardService3/ScorecardGenerator.asmx')
          -> AddItem (SOAP::Data->name('vchScript' => 'xxx')->type
          ('string'),
          SOAP::Data->name('dtLastRan' => '06/26/2002')->type('string'),
          SOAP::Data->name('chSuccessFail' => 's')->type('string'),
          SOAP::Data->name('vchAttempted' => '2')->type('string'),
          SOAP::Data->name('vchFailed' => '1')->type('string'),
          SOAP::Data->name('vchErrorMsg' => 'ppp')->type('string'),
          SOAP::Data->name('iCategory' => 1)->type('int'));

          The trace error message says:
          <faultstring>System.Web.Services.Protocols.SoapException: Server did
          not recognize the value of HTTP Header SOAPAction:
          http://net.trustnet.com/ScorecardService3/#AddItem.

          ==========

          Why does it append a "#"??
        • Duncan Cameron
          ... That is what SOAP::Lite does by default. You need the on_action() method to override that default. As I explained previously - on_action(sub { join( / ,
          Message 4 of 10 , Jul 1, 2002
          • 0 Attachment
            On 2002-07-01 soapnewby wrote:
            >--- In soaplite@y..., rjray@b... wrote:
            >>... look to see what the server is
            >> expecting as a SOAPAction for the given operation.
            >
            >The .wsdl file says
            ><soap:operation
            >soapAction="http://net.trustnet.com/ScorecardService3/AddItem"
            >style="document" />
            >
            >When I try this simpler version of the code:
            >
            >SOAP::Lite
            > -> uri('http://net.trustnet.com/ScorecardService3/')
            > -> proxy
            >('http://net.trustnet.com/ScorecardService3/ScorecardGenerator.asmx')
            > -> AddItem (SOAP::Data->name('vchScript' => 'xxx')->type
            >('string'),
            > SOAP::Data->name('dtLastRan' => '06/26/2002')->type('string'),
            > SOAP::Data->name('chSuccessFail' => 's')->type('string'),
            > SOAP::Data->name('vchAttempted' => '2')->type('string'),
            > SOAP::Data->name('vchFailed' => '1')->type('string'),
            > SOAP::Data->name('vchErrorMsg' => 'ppp')->type('string'),
            > SOAP::Data->name('iCategory' => 1)->type('int'));
            >
            >The trace error message says:
            ><faultstring>System.Web.Services.Protocols.SoapException: Server did
            >not recognize the value of HTTP Header SOAPAction:
            >http://net.trustnet.com/ScorecardService3/#AddItem.
            >
            >==========
            >
            >Why does it append a "#"??
            >
            That is what SOAP::Lite does by default. You need the on_action()
            method to override that default. As I explained previously

            ->on_action(sub { join('/', @_)})

            does the job. All it is doing is joining your uri with your method.
            In your example above, you already have a trailing '/' on your uri
            so you want to join with an empty string:

            ->on_action(sub { join('', @_)})

            The other problem with your example is that your method won't be in the
            correct namespace. You do need something like

            ->call(SOAP::Data->name('AddItem')->attr({xmlns => 'your namespace'})

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