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

soap::lite client sending request to .net service

Expand Messages
  • justin122345
    Hello, Please bear with me, as I m new to using the SOAP::Lite module. I have to write a client app that makes a request to a .NET service and according to the
    Message 1 of 2 , Sep 27, 2004
    • 0 Attachment
      Hello,

      Please bear with me, as I'm new to using the SOAP::Lite module.

      I have to write a client app that makes a request to a .NET service
      and according to the service the request must look like this:

      <?xml version="1.0" encoding="utf-8" ?>
      <PolicySpecification>
      <Policy>
      <Product>
      <ProductCode>006700</ProductCode>
      <PlanId>21577</PlanId>
      <TransactionType>quote</TransactionType>
      <OptionalPackages>
      <FlightGuard>100000</FlightGuard>
      <CollisionDamageWaiver>
      <Cars>2</Cars>
      <Days>7</Days>
      </CollisionDamageWaiver>
      </OptionalPackages>
      </Product>
      <Travelers>
      <Traveler>
      <TripCost>300.00</TripCost>
      <BirthDate>01/01/1979</BirthDate>
      </Traveler>
      <Traveler>
      <TripCost>700.00</TripCost>
      <BirthDate>01/01/1979</BirthDate>
      </Traveler>
      </Travelers>
      <Trip>
      <DepartureDate>11/22/2004</DepartureDate>
      <ReturnDate>11/27/2004</ReturnDate>

      <InitialTripDepositDate>04/04/2004</InitialTripDepositDate>
      </Trip>
      </Policy>
      </PolicySpecification>

      Now I've seen that I'm supposed to use SOAP::Data to dress up the call
      for .NET, but I've only seen it done when one or two parameters must
      be sent over, how do I get to work with something more complex? The
      following is my feeble attempt at it:

      #!/usr/bin/perl -w

      use SOAP::Lite +trace => all;

      my $soap = SOAP::Lite-> uri('http://website.com')
      -> on_action( sub { join '/',
      'http://website.com', $_[1] } )
      ->proxy('http://website.com/services.asmx');
      $soap->encoding('utf-8');
      my $method = SOAP::Data->name('GetQuote')
      ->attr({xmlns => 'http://website.com/'});

      my %param = (
      PolicySpecification => {
      Policy => {
      Product => { ProductCode => 006700,
      PlanId => 21577,
      TransactionType => "quote",
      OptionalPackages => {
      FlightGuard => 100000,
      CollisionDamageWaiver => {
      Cars => 2,
      Days => 7,
      },
      },
      },
      Travelers => [
      { Traveler => { TripCost => 300.00, BirthDate => "01/01/1979" }},
      { Traveler => { TripCost => 700.00, BirthDate => "01/01/1979" }},
      ],
      Trip => { DepartureDate => "11/22/2004",
      ReturnDate => "11/27/2004",
      InitialTripDepositDate => "04/04/2004"
      }
      }
      }
      );
      print $soap->call($method => %param)->result;

      Everytime I run it I get a response from the service but its always an
      error "Value can not be null: Parameter name s".

      Any suggestions?

      Justin
    • Duncan Cameron
      ... When I used SOAP::Lite to connect to dot net a couple of years ago I found that I had to do these 1) specify 2001 schema on the soap constructor
      Message 2 of 2 , Sep 28, 2004
      • 0 Attachment
        At 2004-09-27, 21:14:09 justin122345 <justin122345@...> wrote:

        >Hello,
        >
        >Please bear with me, as I'm new to using the SOAP::Lite module.
        >
        >I have to write a client app that makes a request to a .NET service
        >and according to the service the request must look like this:
        >
        ><?xml version="1.0" encoding="utf-8" ?>
        ><PolicySpecification>
        > <Policy>
        > <Product>
        > <ProductCode>006700</ProductCode>
        > <PlanId>21577</PlanId>
        > <TransactionType>quote</TransactionType>
        > <OptionalPackages>
        > <FlightGuard>100000</FlightGuard>
        > <CollisionDamageWaiver>
        > <Cars>2</Cars>
        > <Days>7</Days>
        > </CollisionDamageWaiver>
        > </OptionalPackages>
        > </Product>
        > <Travelers>
        > <Traveler>
        > <TripCost>300.00</TripCost>
        > <BirthDate>01/01/1979</BirthDate>
        > </Traveler>
        > <Traveler>
        > <TripCost>700.00</TripCost>
        > <BirthDate>01/01/1979</BirthDate>
        > </Traveler>
        > </Travelers>
        > <Trip>
        > <DepartureDate>11/22/2004</DepartureDate>
        > <ReturnDate>11/27/2004</ReturnDate>
        >
        ><InitialTripDepositDate>04/04/2004</InitialTripDepositDate>
        > </Trip>
        > </Policy>
        ></PolicySpecification>
        >
        >Now I've seen that I'm supposed to use SOAP::Data to dress up the call
        >for .NET, but I've only seen it done when one or two parameters must
        >be sent over, how do I get to work with something more complex? The
        >following is my feeble attempt at it:
        >
        >#!/usr/bin/perl -w
        >
        >use SOAP::Lite +trace => all;
        >
        >my $soap = SOAP::Lite-> uri('http://website.com')
        > -> on_action( sub { join '/',
        >'http://website.com', $_[1] } )
        > ->proxy('http://website.com/services.asmx');
        >$soap->encoding('utf-8');
        >my $method = SOAP::Data->name('GetQuote')
        > ->attr({xmlns => 'http://website.com/'});
        >
        >my %param = (
        > PolicySpecification => {
        > Policy => {
        > Product => { ProductCode => 006700,
        > PlanId => 21577,
        > TransactionType => "quote",
        > OptionalPackages => {
        > FlightGuard => 100000,
        > CollisionDamageWaiver => {
        > Cars => 2,
        > Days => 7,
        > },
        > },
        > },
        > Travelers => [
        > { Traveler => { TripCost => 300.00, BirthDate => "01/01/1979"
        >}},
        > { Traveler => { TripCost => 700.00, BirthDate => "01/01/1979"
        >}},
        > ],
        > Trip => { DepartureDate => "11/22/2004",
        > ReturnDate => "11/27/2004",
        > InitialTripDepositDate => "04/04/2004"
        > }
        > }
        > }
        >);
        >print $soap->call($method => %param)->result;
        >
        >Everytime I run it I get a response from the service but its always an
        >error "Value can not be null: Parameter name s".
        >
        >Any suggestions?

        When I used SOAP::Lite to connect to dot net a couple of years ago I
        found that I had to do these

        1) specify 2001 schema on the soap constructor
        ->xmlschema('2001')
        2) explicitly type each element, e.g.
        SOAP::Data->name(AisleSide => $p{side})->type('string'),

        From the error message that you are getting, I would guess that s is a
        variable in the server code. Have a word with the server developer to
        find out what it is referring to.
        Also, turn on trace so that you can see the SOAP envelope that is being
        generated.

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