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

Adding attributes to envelope tag / changing name of a body tag

Expand Messages
  • gtbaddy
    Hi, thanks to the help Martin gave me in my previous post I am getting much closer to having things working. I am successfully sending calls to the service
    Message 1 of 2 , Jan 14, 2011
    View Source
    • 0 Attachment
      Hi, thanks to the help Martin gave me in my previous post I am getting much closer to having things working. I am successfully sending calls to the service using SOAP::Lite now, but I am still having trouble getting it to build the XML exactly as I need it.

      I have been using the tool soapUI to test some calls to this web service, so it has been a good help since it gives me some examples of what XML works with this web service. I have been comparing it with the XML that SOAP::Lite is generating and I have identified the two parts that are wrong causing my calls not to work.

      1. My call from SOAP::Lite uses the following envelope tag:

      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

      I need to get the envelop tag to have these attributes instead:

      <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.scene7.com/IpsApi/xsd" xmlns:ns="http://www.scene7.com/IpsApi/xsd/2010-01-31">


      Is there a way for me to have precise control over the those namespace attributes on the envelope (specifically xmlns:xsd & xmlns:ns)?

      2. I am using the following code to pass paramaters to the method checkLogin:

      my $params = SOAP::Data->name("ns:checkLoginParam" =>
      \SOAP::Header->value(
      SOAP::Header->name('ns:email')->value($s7user)->type(''),
      SOAP::Header->name('ns:password')->value($s7pass)->type(''),
      ));

      # request method
      $soap->call('checkLogin', $params, $authHeader);


      .. this produces the following xml ...

      <soap:Body>
      <checkLogin xmlns="http://www.scene7.com/IpsApi/xsd/2010-01-31">
      <ns:checkLoginParam>
      <ns:email>myemail/ns:email>
      <ns:password>mypass</ns:password>
      </ns:checkLoginParam>
      </checkLogin>
      </soap:Body>

      Is there a way for me to remove the checkLogin tag from being wrapped around checkLoginParam? The working code that I have from soapUI that I am attempting to reproduce is this:

      <soap:Body>
      <ns:checkLoginParam>
      <ns:email>myemail</ns:email>
      <ns:password>mypass</ns:password>
      </ns:checkLoginParam>
      </soap:Body>

      Thanks for your time all,
      Patrick
    • Martin Busik
      Hi, ... the prefixes (e.g. soap is refered to as prefix when defined by xmlns:soap , wich means you write soap:Envelope ) do not really care, you can name
      Message 2 of 2 , Feb 12, 2011
      View Source
      • 0 Attachment
        Hi,

        > 1. My call from SOAP::Lite uses the following envelope tag:
        >
        > <soap:Envelope
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        > soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        >
        > I need to get the envelop tag to have these attributes instead:
        >
        > <soap:Envelope
        > xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
        > xmlns:xsd="http://www.scene7.com/IpsApi/xsd"
        > xmlns:ns="http://www.scene7.com/IpsApi/xsd/2010-01-31">

        the prefixes (e.g. "soap" is refered to as prefix when defined by
        "xmlns:soap", wich means you write "soap:Envelope")
        do not really care, you can name them as you want.

        I see a difference in the Envelope uri:

        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

        vs.

        xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

        I'haven't checked the differences yet, but there may some differences
        occur...



        > my $params = SOAP::Data->name("ns:checkLoginParam" =>
        > \SOAP::Header->value(
        > SOAP::Header->name('ns:email')->value($s7user)->type(''),
        > SOAP::Header->name('ns:password')->value($s7pass)->type(''),
        > ));
        >
        > # request method
        > $soap->call('checkLogin', $params, $authHeader);
        >
        >
        > .. this produces the following xml ...
        >
        > <soap:Body>
        > <checkLogin xmlns="http://www.scene7.com/IpsApi/xsd/2010-01-31">
        > <ns:checkLoginParam>
        > <ns:email>myemail/ns:email>
        > <ns:password>mypass</ns:password>
        > </ns:checkLoginParam>
        > </checkLogin>
        > </soap:Body>
        >
        > Is there a way for me to remove the checkLogin tag from being
        > wrapped around checkLoginParam? The working code that I have
        > from soapUI that I am attempting to reproduce is this:
        >
        > <soap:Body>
        > <ns:checkLoginParam>
        > <ns:email>myemail</ns:email>
        > <ns:password>mypass</ns:password>
        > </ns:checkLoginParam>
        > </soap:Body>

        "checkLogin" is the main body element, it is refered to as "method name".

        This is, because your code uses: $soap->call('checkLogin',

        The example you have given seems to expect a method "checkLoginParam", which
        would be
        coded as: $soap->call('checkLoginParam',...

        If your email an password elements shall come inside the Body element, you
        should create them
        with SOAP::Data and not SOAP::Header. SOAP::Header is intended to "tell"
        SOAP::Lite to put its
        contents into the Envelope element (instead of into Body)

        HTH,
        Martin
      Your message has been successfully submitted and would be delivered to recipients shortly.