Perl sends SOAP requests

Source: Internet
Author: User
The project needs to send soap messages for some operations. Because the SOAP protocol is built on the HTTP protocol, this problem can also be solved by sending HTTP requests. In addition, the project also needs to consider support for the SSL protocol. Method 1: Use soap: lite (third-party Perl Library) to implement use soap: lite; my $ proxy = 'HTTP: // host: Port /... /...? WSDL '; my $ soap = soap: Lite-> proxy ($ proxy)-> NS ('... '); my $ response = $ soap-> call ('... '); because you do not want to introduce a third-party library, this method is not used later. Method 2: Use lwp to implement Use http: headers; Use http: request;
Use lwp: useragent; my $ Server = '...';
# Get SOAP request format my $ content = '...'; # Set HTTP Header
My $ head = http: headers-> New ();
$ Head-> content_type ('text/XML; charset = UTF-8 '); # Set HTTP request and send it
My $ request = http: Request-> New (post, $ server, $ head );
$ Request-> protocol ('HTTP/1.0 ');
$ Request-> content ($ content );
My $ useragent = lwp: useragent-> New ();
My $ response = $ useragent-> request ($ request); Because lwp is a built-in Perl library, there is no problem of using a third-party library. However, to support the SSL protocol, I/O: Socket: SSL, net: SSL, and other third-party libraries must be introduced. Method 3: use the curl command to implement my $ httpurl = $ argv [0]; my $ result = ""; my $ content = '... '; if ($ httpurl = ~ /^ Https/) {my $ certdir = $ argv [1]; $ result = 'curl-k -- silent -- cacert $ certdir /***. PEM -- Cert $ certdir /***. pem' $ httpurl '-d' $ content '';} else {$ result = 'curl -- silent' $ httpurl'-d' $ content '';} this method depends on the curl command, which provides better SSL support and is easy to implement.

Perl sends SOAP requests

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.