Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

I don't understand how to send SOAP data using LWP's user agent

by ted.byers (Monk)
on Sep 08, 2014 at 16:58 UTC ( [id://1099876]=perlquestion: print w/replies, xml ) Need Help??

ted.byers has asked for the wisdom of the Perl Monks concerning the following question:

I have read the documentation for useragent, and have made it work properly in terms of connecting to a server that requires a client side certificate, with full validation. However, while I can correctly construct the XML required for the SOAP data, I can't seem to send it correctly to the server. I have tried function request in two ways: $ua->request($r,'fsd.xml'); AND $ua->request($r,$data);, but in both cases, I get an exception from the server complaining that it gets no data.

I guess this boils down to two questions: 1) How do I send SOAP XML data? 2) How would I write a CGI program, on one of my own servers, that I could use to verify that the SOAP XML data is received correctly (NB: I know well how to write CGI scripts to process form data, but this isn't form data.)

I'd appreciate any insights you can provide. I have read the documentation, but it isn't clear enough for me to resolve this.

Thanks

Ted

Replies are listed 'Best First'.
Re: I don't understand how to send SOAP data using LWP's user agent
by Corion (Patriarch) on Sep 08, 2014 at 17:51 UTC

    Assuming that $r is a HTTP::Request, I would pass the request data in using the ->content method of HTTP::Request instead of relying on the magic of LWP::UserAgent picking up the correct file or knowing what to do with $data.

    Also, have you looked at what SOAP::Lite XML would construct as a request? If you can get SOAP::Lite to construct the request for you, maybe you can compare that with the request your program constructs and find the difference?

      Thanks

      The content function of HTTP::Request was the key. I also used the header function to set the content type as text/xml. That got it working, in the sense I now have proof that my code is sending content, and that the server is processing it.

      I did look at SOAP::Lite, but it seemed like overkill as all these guys use SOAP for is to structure the XML messages it expects to receive and those it sends in response.

      Thanks

      Ted

Re: I don't understand how to send SOAP data using LWP's user agent
by Anonymous Monk on Sep 09, 2014 at 00:36 UTC

      Thanks. That's a little light reading. ;-)

      Ted

Re: I don't understand how to send SOAP data using LWP's user agent
by iguanodon (Priest) on Sep 09, 2014 at 12:19 UTC

      Thanks.

      Alas, I do not have access to the server logs. I did not create this server, and do not have access to it's code. What I have learned is that the guys responsible have coded it in Java, as a servlet. It does not handle errors well (key java exception data is passed to the client rather than processed server side; with only suitably sanitized but useful error messages being sent to the client). I regard passing a full stack trace to a client as poor practice; but that's just me I suppose.

      I will have to look into the SOAPAction HTTP header. At present, I only set the content type header as text/xml

      I will definitely take a look at use of $q->param('POSTDATS'); to get data that was not collected from a form.

      Thanks again

      Ted

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1099876]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found