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

How to add authHeader to Soap Request

Expand Messages
  • Tobias Richter
    Hi *, I try to write a simple Perl SOAP Client for these services: http://almdemo.polarion.com/polarion/ws/services/SessionWebService?wsdl
    Message 1 of 2 , Dec 12, 2011
    • 0 Attachment
      Hi *,

      I try to write a simple Perl SOAP Client for these services:

      http://almdemo.polarion.com/polarion/ws/services/SessionWebService?wsdl
      http://almdemo.polarion.com/polarion/ws/services/TrackerWebService?wsdl
      http://almdemo.polarion.com/polarion/ws/services/ProjectWebService?wsdl


      My script looks like this now:
      ---snip---
      ...
      my $SessionWebServicesoap = SOAP::Lite
      -> proxy($SessionWebServiceURI)
      -> uri($SessionWebServiceURI);

      my $TrackerWebServicesoap = SOAP::Lite
      -> proxy($TrackerWebServiceURI)
      -> uri($TrackerWebServiceURI);

      my $ProjectWebServicesoap = SOAP::Lite
      -> proxy($ProjectWebServiceURI)
      -> uri($ProjectWebServiceURI);

      my $response;

      print "\n";

      #get session
      my $session = $SessionWebServicesoap->logIn(
      SOAP::Data->name('userName')->value($user),
      SOAP::Data->name('password')->value($password)
      );
      my $sessionID = $session->{'_content'}[2][0][4]{'sessionID'};
      print "session is: ".$sessionID."\n";

      my $authHeader = SOAP::Header->name('sessionID')->value($sessionID);

      $response = $ProjectWebServicesoap->getProject("productbacklog");
      die $response->faultstring if ($response->fault);
      my $IObject = $response->result;
      print $response->result, "\n";

      $response = $TrackerWebServicesoap->createWorkItem($IObject,$authHeader);
      die $response->faultstring if ($response->fault);
      print $response->result, "\n";


      exit;
      ---snap---


      Unfortunately I always get the following error message:
      session is: 9109123277697179703
      Project=HASH(0x6b6c4e0)
      com.polarion.platform.security.PermissionDeniedException: Permission
      com.polarion.persistence.object.WorkItem.key.created.modify denied for
      user null in context null at soap6.pl line 56.


      Do you have a idea how to add the session ID to my SOAP-Request Header?

      I think somebody had the same problem with python's suds here:
      https://fedorahosted.org/suds/ticket/233



      Thank you.
      Tobias
    • Tobias Richter
      Hi *, sorry, about Double posting - I thought that my first message hasn t transmitted correctly. ... my $SessionWebServicesoap = SOAP::Lite - readable(1)
      Message 2 of 2 , Dec 12, 2011
      • 0 Attachment
        Hi *,

        sorry, about Double posting - I thought that my first message hasn't
        transmitted correctly.

        In the meantime I was able to solve the problem by myself:

        ---snip---
        my $SessionWebServicesoap = SOAP::Lite

        ->readable(1)

        ->proxy($SessionWebServiceURI)

        ->uri($SessionWebServiceURI)

        ;

        $SessionWebServicesoap->autotype(0);

        my $SessionWebServicesoapSerializer = $SessionWebServicesoap->serializer();

        $SessionWebServicesoapSerializer->register_ns(
        'http://ws.polarion.com/session', 'ns1' );



        my $ProjectWebServicesoap = SOAP::Lite

        ->readable(1)

        ->proxy($ProjectWebServiceURI)

        ->uri($ProjectWebServiceURI)

        ;

        $ProjectWebServicesoap->autotype(0);

        my $ProjectWebServicesoapSerializer = $ProjectWebServicesoap->serializer();

        $ProjectWebServicesoapSerializer->register_ns(
        'http://ws.polarion.com/session', 'ns1' );





        my $TrackerWebServicesoap = SOAP::Lite

        ->readable(1)

        ->proxy($TrackerWebServiceURI)

        ->uri($TrackerWebServiceURI)

        ;

        $TrackerWebServicesoap->autotype(0);

        my $TrackerWebServicesoapSerializer = $TrackerWebServicesoap->serializer();

        $TrackerWebServicesoapSerializer->register_ns(
        'http://ws.polarion.com/session', 'ns1' );



        my $response;



        print "\n";



        #get session

        my $session = $SessionWebServicesoap->logIn(

        SOAP::Data->name('userName')->value($user),

        SOAP::Data->name('password')->value($password)

        );

        my $sessionID = $session->{'_content'}[2][0][4]{'sessionID'};

        print "session is: ".$sessionID."\n";



        my $authHeader = SOAP::Header->name('ns1:sessionID')->value($sessionID);



        $response = $TrackerWebServicesoap->getWorkItemById("projectname",
        "TEST-1", $authHeader);

        die $response->faultstring if ($response->fault);

        print Dumper($response->result);


        ---snap---

        The important stuff is the "register_ns" and the "$authheader" part.
        Now it works perfect and I can go forward with this script... :)

        Maybe somebody will find this solution useful in future.


        Best regards,
        Tobias
      Your message has been successfully submitted and would be delivered to recipients shortly.