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

Re: Calling .Net web Service with SOAP headers

Expand Messages
  • jpeyser
    A few more changes... 1. Use - proxy instead of - schema. 2. Redefine SOAP::Serializer::gen_ns to suppress the generic namespace1 prefix. 3. Apparently
    Message 1 of 6 , Nov 14, 2003
      A few more changes...

      1. Use ->proxy instead of ->schema.
      2. Redefine SOAP::Serializer::gen_ns to suppress the
      generic 'namespace1' prefix.
      3. Apparently ->attr overrides ->mustUnderstand(1), so add
      'SOAP-ENV:mustUnderstand' => "1" to attr hash.
      4. Use autotype(0) to suppress types.

      sub SOAP::Serializer::gen_ns {}
      .
      .
      .
      my $soap = SOAP::Lite ->uri($uri)
      ->proxy($proxy)
      ->autotype(0);


      my $response = $soap->AuthentifyUser(
      SOAP::Header->name($hdrname => \SOAP::Header->value(
      SOAP::Data ->name(hdrAppId => $hdrAppId)->prefix($hdrns),
      SOAP::Data ->name(hdrDevId => $hdrDevId)->prefix($hdrns),
      SOAP::Data ->name(hdrDevName => $hdrDevName)->prefix($hdrns),
      )
      )->attr({'xmlns:wsse'=>$uri, 'SOAP-ENV:mustUnderstand' => "1"})-
      >prefix($hdrns),
      SOAP::Data ->name(username => $username)->attr({'xmlns:SOAPSDK4'
      => $uri}),
      SOAP::Data ->name(password => $password)->attr({'xmlns:SOAPSDK5'
      => $uri}),
      SOAP::Data ->name(provider => $provider)->attr({'xmlns:SOAPSDK6'
      => $uri}),
      )->attr({xmlns=>$uri});


      Jonathan

      --- In soaplite@yahoogroups.com, "alakazoodotcom" <alakazoo@a...>
      wrote:
      > Hi,
      >
      > For the last 2 days, I'm trying to call a .Net web service with
      SOAP
      > headers with SOAP::Lite but I'm getting this message "405 Method
      Not
      > Allowed at" when I try to use
      > my $soap = SOAP::Lite->uri($uri)->proxy($proxy);
      >
      > If I try
      > my $soap = SOAP::Lite->uri($uri)->schema($proxy);
      > or
      > my $soap = SOAP::Lite->uri($uri)->service($proxy);
      >
      > then I'm getting "Can't call method "attr" on an undefined value
      at "
      >
      > I have read this post
      > http://groups.yahoo.com/group/soaplite/message/2750 but I can't
      > figure out what's wrong with my script.
      >
      > Here is my code, the SOAP envelop generated by the script and the
      > SOAP envelop that should be created by the script.
      >
      > I'm running Active State Perl for Windows
      >
      > If someone could help me, it will be appreciate
      >
      > If you need something else, just tell me.
      >
      > Thank you,
      >
      > Pierre
      >
      >
      > My Code :
      >
      > #--------------------------------
      > #!/usr/bin/perl -w
      >
      > use SOAP::Lite +trace;
      > use strict;
      >
      >
      > # Web service's AuthentifyUser parameters
      > my $username = "username"; # user's username
      > my $password = "password"; # user's password
      > my $provider = "providerID"; # this parameter should
      > never be changed
      >
      > # Web service's SecurityContext header parameters
      > # those parameters should never be changed
      > my $hdrname = "SecurityContext";
      > # header name
      > my $hdrns = "wsse";
      > # header namespace
      > my $hdrAppId = "AF11A181-EEB3-4703-B0A6-04CC14F7F040";
      > # Application ID
      > my $hdrDevId = "0C09622F-D413-4607-A75C-952112E832E5";
      > # Development ID
      > my $hdrDevName = "4AFB1C23-AC65-436E-8CD6-
      5090FBA18735";
      > # Development name
      >
      > # Web service's properties
      > my $proxy
      > = "http://www.mydomain.com/ws/secure/wsAuthenticationApp.wsdl
      > ";
      > my $uri = "http://tempuri.org/";
      >
      >
      > # Initialize the Soap Client
      > my $soap = SOAP::Lite ->uri($uri)
      > #->proxy($proxy);
      > ->schema($proxy);
      > #->service($proxy);
      >
      >
      > # send the request with header and trap result
      > my $response = $soap->AuthentifyUser(
      >
      > # Set header parameters
      >
      > SOAP::Header ->new ( name => $hdrname,
      >
      >
      > value=> \SOAP::Header->value(
      >
      >
      >
      > SOAP::Data ->name(hdrAppId => $hdrAppId)
      >
      >
      >
      > # ->prefix($hdrns)
      >
      >
      >
      > ->type(''),
      >
      >
      >
      > SOAP::Data ->name(hdrDevId => $hdrDevId)
      >
      >
      >
      > # ->prefix($hdrns)
      >
      >
      >
      > ->type(''),
      >
      >
      >
      > SOAP::Data ->name(hdrDevName => $hdrDevName)
      >
      >
      >
      > # ->prefix($hdrns)
      >
      >
      >
      > ->type(''),
      >
      >
      > )
      >
      > )
      >
      > ->attr
      > ({xmlns=>$uri}),
      >
      > #->prefix($hdrns),
      >
      > # Set body parameters
      >
      > SOAP::Data ->name(username => $username)
      >
      > ->attr({xmlns => $uri})-
      > >prefix('')->type(''),
      >
      > SOAP::Data ->name(password => $password)
      >
      > ->attr({xmlns => $uri})-
      > >prefix('')->type(''),
      >
      > SOAP::Data ->name(provider => $provider)
      >
      > ->attr({xmlns => $uri})-
      > >prefix('')->type(''),
      >
      > )
      > ->attr({xmlns=>$uri})
      > ->prefix('');
      >
      > print "response = $response\n";
      >
      > # get the result and print the error message if it failed
      > if (defined (my $result = $response->result)) {
      > print "result = $result\n";
      > }
      > else {
      > print "Fault: ", $response->faultstring, "\n",
      > "Detail:\n", $response->faultdetail, "\n";
      > }
      > -------------------------------------
      > SOAP envelop generated by the script
      >
      > <?xml version="1.0" encoding="UTF-8"?>
      > <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-
      > instance" xmlns:SOAP-
      ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
      > ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      > <SOAP-ENV:Body>
      > <AuthentifyUser xmlns="">
      > <SecurityContext xmlns="http://tempuri.org/">
      > <hdrAppId>AF11A181-EEB3-4703-B0A6-04CC14F7F040</hdrAppId>
      > <hdrDevId>0C09622F-D413-4607-A75C-952112E832E5</hdrDevId>
      > <hdrDevName>4AFB1C23-AC65-436E-8CD6-5090FBA18735</hdrDevName>
      > </SecurityContext>
      > <username xmlns="http://tempuri.org/">rauclair</username>
      > <password xmlns="http://tempuri.org/">rauclair</password>
      > <provider xmlns="http://tempuri.org/">93</provider>
      > </AuthentifyUser>
      > </SOAP-ENV:Body>
      > </SOAP-ENV:Envelope>
      >
      > -------------------------------------
      > SOAP envelop that should be created
      >
      > <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      > <SOAP-ENV:Envelope
      xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema"
      > xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"
      > xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/"
      > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      > <SOAP-ENV:Header>
      > <wsse:SecurityContext xmlns:wsse="http://tempuri.org/" SOAP-
      > ENV:mustUnderstand="1">
      > <wsse:hdrAppId>56DA5A9C-3C51-49D3-BC60-D2934BAE15A9</wsse:hdrAppId>
      > <wsse:hdrDevId>2A02E531-5578-4303-9805-93AF84A80E92</wsse:hdrDevId>
      > <wsse:hdrDevName>7978D02E-2142-4C79-88DA-
      > 3A7F2EC812CD</wsse:hdrDevName>
      > </wsse:SecurityContext>
      > </SOAP-ENV:Header>
      > <SOAP-ENV:Body>
      > <AuthentifyUser xmlns="http://tempuri.org/">
      > <username xmlns:SOAPSDK4="http://tempuri.org/">rauclair</username>
      > <password xmlns:SOAPSDK5="http://tempuri.org/">kdbm55tk</password>
      > <provider xmlns:SOAPSDK6="http://tempuri.org/">91</provider>
      > </AuthentifyUser>
      > </SOAP-ENV:Body>
      > </SOAP-ENV:Envelope>
      >
      > -------------------------------------
      > SOAP envelop returned by the web service
      >
      > <?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:Header>
      > <SecurityContext soap:mustUnderstand="1"
      xmlns="http://tempuri.org/">
      > <hdrAppId>56DA5A9C-3C51-49D3-BC60-D2934BAE15A9</hdrAppId>
      > <hdrDevId>2A02E531-5578-4303-9805-93AF84A80E92</hdrDevId>
      > <hdrDevName>7978D02E-2142-4C79-88DA-3A7F2EC812CD</hdrDevName>
      > </SecurityContext>
      > </soap:Header>
      > <soap:Body>
      > <AuthentifyUserResponse xmlns="http://tempuri.org/">
      > <AuthentifyUserResult><NewDataSet> <Table>
      > <SessionPartnerKey>6b5daa6b-22a6-4782-b8ea-
      > fa90ec04d6d6</SessionPartnerKey>
      > <SessionPartnerAuthentified>true</SessionPartnerAuthentified>
      > <SessionPartnerKeyExp>2003-11-14T12:44:18.4330000-
      > 05:00</SessionPartnerKeyExp> </Table>
      > </NewDataSet></AuthentifyUserResult>
      > </AuthentifyUserResponse>
      > </soap:Body>
      > </soap:Envelope>
    • alakazoodotcom
      Thanks for your reply Jonathan. My SOAP envelope is now correct Can you explain me the difference between - proxy - schema - service Do you have any ideas for
      Message 2 of 6 , Nov 14, 2003
        Thanks for your reply Jonathan.

        My SOAP envelope is now correct

        Can you explain me the difference between
        ->proxy
        ->schema
        ->service

        Do you have any ideas for the "405 method not allowed" error
        message ?

        Thanks again

        Pierre
      • alakazoodotcom
        ... Maybe it could help if I mention that in VB I use this : oSoapClient.ClientProperty( ServerHTTPRequest ) = True Thanks again Pierre
        Message 3 of 6 , Nov 14, 2003
          > Do you have any ideas for the "405 method not allowed" error
          > message ?

          Maybe it could help if I mention that in VB I use this :
          oSoapClient.ClientProperty("ServerHTTPRequest") = True


          Thanks again

          Pierre
        • jpeyser
          On second thought, my solution will not work. The method is either POST or GET. A proxy call will submit a POST, while a service call will submit a GET. If the
          Message 4 of 6 , Nov 14, 2003
            On second thought, my solution will not work.

            The method is either POST or GET. A proxy call will submit a POST,
            while a service call will submit a GET. If the proxy address is a
            WSDL file, then you have to use a service call to get the WSDL file,
            which is why you received a "405 method not allowed".

            The WSDL file contains the actual proxy address in the service
            section. If you use that address, my solution may work.

            I will defer to others more knowledgable to answer your question
            about proxy, schema, and service.

            --- In soaplite@yahoogroups.com, "alakazoodotcom" <alakazoo@a...>
            wrote:
            > Thanks for your reply Jonathan.
            >
            > My SOAP envelope is now correct
            >
            > Can you explain me the difference between
            > ->proxy
            > ->schema
            > ->service
            >
            > Do you have any ideas for the "405 method not allowed" error
            > message ?
            >
            > Thanks again
            >
            > Pierre
          • alakazoodotcom
            Everything works fine except this error message mismatched tag at line 63, column 16, byte 2921 at C:/Program Files/Perl/site/lib/XML/Parser.pm line 185 I ve
            Message 5 of 6 , Nov 17, 2003
              Everything works fine except
              this error message

              mismatched tag at line 63, column 16, byte 2921 at C:/Program
              Files/Perl/site/lib/XML/Parser.pm line 185

              I've read that I should use XML::Parser::Lite then I tried
              $SOAP::Constants::DO_NOT_USE_XML_PARSER = 1;
              but I got this message
              mismatched tag 'ul'


              Any ideas ?

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