#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Parsing results from soap:lite


    I need some help getting the results from a soap service that I called. I'm able to successfully make the call and using Dumper($result) I can see the response. I need to parse the application return code and return message so I can check there values. By referencing $result->fault I know the soap call did not fail. However I'm not able to make the same reference to get the value of "ReturnCode" and "ReturnMessage"
    How do I get these values?



    A sample of the code and dumper output is below.



    Dumper output sample: (xxx added to urls)
    <soap:Envelope
    xmlns:soap="httxxxp://schemas.xmlsoap.org/soap/envelope/"
    xmlns:soapenc="httxxxp://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="htxxxtp://wwxxxw.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="htxxxtp://wwxxxw.w3.org/2001/XMLSchema">
    <soap:Body>
    <ns:AddDevelopmentInfoResponse xmlns:ns="urn:RULES:SOAP:ProjMgmtStatelessIntegrator:Mgmt-Work">
    <ReturnValues>
    <ReturnCode>5</ReturnCode>
    <ReturnMessage>The item ID is invalid: Item ID not found in system</ReturnMessage>
    </ReturnValues>
    </ns:AddDevelopmentInfoResponse>
    </soap:Body>
    </soap:Envelope>




    Code sample:
    #setup the necessary SOAP parameters
    my $soapres = SOAP::Lite
    -> proxy('httxxxp://mfstg.com/web/SOAPServlet')
    -> uri('urn:RULES:SOAP:ProjMgmtStatelessIntegrator:Mgmt-Work');

    $result=$soapres->AddDevelopmentInfo($request);

    #Debuging code: Uncomment to see full response from PMF
    unless ($result->fault) {
    print STDERR "NoFault\n";
    print STDERR $result->result()."\n";
    } else {
    print STDERR "Fault\n";
    print STDERR join ', ',
    $result->faultcode,
    $result->faultstring,
    $result->faultdetail;
    }
  2. #2
  3. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,261
    Rep Power
    1810
    What dumper output?

    Code:
    #Debuging code: Uncomment to see full response from PMF
    unless ($result->fault) {
       print STDERR "NoFault\n";
       print STDERR $result->result()."\n";
    } else {
       print STDERR "Fault\n";
       print STDERR join ', ',
       $result->faultcode,
       $result->faultstring,
       $result->faultdetail;
    }
    Is that the output from
    Code:
    print STDERR $result->result()."\n";
    Note that unless($result->fault) means no fault, so I wouldn't expect what follows to go to STDERR. But anyway, the server is replying with XML, so you need to parse the XML to get at the data inside. I recommend feeding $result->result to XML::Simple for a fairly easy solution.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    The dumper code was not in the code snippet. it would be
    Dumper($result); This will dump the content of $result.



    Originally Posted by keath
    What dumper output?

    Code:
    #Debuging code: Uncomment to see full response from PMF
    unless ($result->fault) {
       print STDERR "NoFault\n";
       print STDERR $result->result()."\n";
    } else {
       print STDERR "Fault\n";
       print STDERR join ', ',
       $result->faultcode,
       $result->faultstring,
       $result->faultdetail;
    }
    Is that the output from
    Code:
    print STDERR $result->result()."\n";
    Note that unless($result->fault) means no fault, so I wouldn't expect what follows to go to STDERR. But anyway, the server is replying with XML, so you need to parse the XML to get at the data inside. I recommend feeding $result->result to XML::Simple for a fairly easy solution.

IMN logo majestic logo threadwatch logo seochat tools logo