I am trying to get access to .NET soap service from perl using SOAP::Lite
and have hit a brickwall....
Many people do. .Net is designed in a way that makes it much harder for non-.Net toolkits to work with it, than it truly needs to be.

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.
You don't say how you used the SOAP::Header object, and it isn't obvious from your example code.

When you create a SOAP::Header object, you're just creating a SOAP::Data object in a different namespace. When SOAP::Lite goes to serialize a request from a call, it looks at all the arguments passed, and any that are blessed into the SOAP::Header namespace go into the Header section, rather than the body. Using your code's call as an example, you should have done:

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

...

my $res = $client->Competitions($head,
{ 'LanguageCode' => 'en',
'SportID' => '1' });
Note that you aren't setting a header with the SOAP::Header->new call, you're creating a data element that must be passed into the later call as a parameter.

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???
The SOAP-ENV vs. soap issue is unimportant. Those are just labels for namespaces; you could call it "Spike" if you wanted.

The bigger problem is with c-gensym3. That is because you didn't give the SOAP call a piece of fully-qualified data; you gave it an anonymous hash reference instead. And .Net services are notorious for being picky and retentive about what they'll accept. Plus, you should be passing LanguageCode and SportID as separate parameters, not a hash. The "Competitions" tag is what identifies the remote operation (as seen by the fact that you are calling $client->Competitions()).

Try using SOAP::Data objects to control how things look:

my $res = $client->Competitions($head, # Don't forget this one :-)
SOAP::Data->name(LanguageCode => 'en'),
SOAP::Data->name(SportID => 1));

(Do I get to shill my web services book? :-)

Randy
--
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Randy J. Ray Campbell, CA http://www.rjray.org [EMAIL PROTECTED]

Silicon Valley Scale Modelers: http://www.svsm.org

Reply via email to