Hi guys,

For the life of me I can't seem to figure this out.

I am trying to get access to .NET soap service from perl using SOAP::Lite
and have hit a brickwall....

This is a VALID xml request.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
  <soap:Header>
    <Authentication xmlns="http://www.xxxxxxxxxx.com/Events";>
      <User>abcde</User>
      <Password>12345</Password>
    </Authentication>
  </soap:Header>
  <soap:Body>
    <Competitions xmlns="http://www.xxxxxxxxxx.com/Events";>
      <LanguageCode>en</LanguageCode>
      <SportID>1</SportID>
    </Competitions>
  </soap:Body>
</soap:Envelope>


I have 2 problems:

1) The Header. I can't seen to find a way of adding the authentication.....
I have tried the following:
    a) SOAP::Header->name(Authentication => {'User' => 'abcde', Password =>
'12345'} );
    b) Setting the HTTP_proxy_[user|pass] variable
    c) adding -
            sub SOAP::Transport::HTTP::Client::get_basic_credentials {
               return 'abcde' => '12345';
            }
None of these have worked.


2) The output from SOAP::Lite (ignoring problem 1) is as follows:

<?xml version="1.0" encoding="UTF-8"?>

    <SOAP-ENV:Envelope xmlns:namesp2="http://xml.apache.org/xml-soap";
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
        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:Body>
        <namesp1:Competitions
xmlns:namesp1="http://www.xxxxxxxxxxxx.com/Events";>
            <c-gensym3 xsi:type="namesp2:SOAPStruct">
                <LanguageCode xsi:type="xsd:string">en</LanguageCode>
                <SportID xsi:type="xsd:int">1</SportID>
            </c-gensym3>
        </namesp1:Competitions>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Which is close but not exactly the same as what is reqired. For example
SOAP-ENV: instead of soap:; and where has the extra element 'c-gensym3' come
from???

Below is my perl code if this helps


Thanks in advance

Andy


<perl>

#!/usr/bin/perl -w

# Test SOAP Application for Bet Internet.

use strict;
use SOAP::Lite +trace => 'all';
use Data::Dumper;
$|++;

#SOAP::Header->name(Authentication => {'User' => 'abcde', Password =>
'12345'} );

my $client = SOAP::Lite
    -> uri('http://www.xxxxxxxxx.com/Events')
    -> proxy('http://soap.xxxxxxxxxx.com/EventService.asmx')
    -> on_action(sub{sprintf '%s/%s', @_ });


sub SOAP::Transport::HTTP::Client::get_basic_credentials {
   return 'abcde' => '12345';
}

my $res = $client->Competitions({ 'LanguageCode' => 'en', 'SportID' =>
'1' });
print Dumper($res);

</perl>


Reply via email to