This section provides a tutorial example on how to test the service() function with a local WSDL document file with a local URL.
With the modified WSDL document stored on my local system,
I am ready to test SOAL::lite for WSDL locally now:
#- GetSpeech_WSDL_localhost.pl
#- Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
#- All rights reserved
#
use SOAP::Lite +trace;
my $result = SOAP::Lite
->service('file:///C:/herong/GetSpeech.wsdl')
->readable('true')
->GetSpeech('To be, or not to be');
Result of GetSpeech_WSDL_localhost.pl:
POST http://localhost/soap11 HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 831
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://xmlme.com/WebServices/GetSpeech"
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://xmlme.com/WebServices">
<soap:Body>
<tns:GetSpeech>
<Request xsi:type="s:string">To be, or not to be</Request>
</tns:GetSpeech>
</soap:Body>
</soap:Envelope>
...
500 Can't connect to localhost:80 (connect: Unknown error)
The result tells me that:
Yes. WSDL can be tested locally without using any real Web service server.
By default, the service() function picked up the "port" defined for SOAP 1.1,
because it uses "POST http://localhost/soap11 HTTP/1.1".
The Envelope is generated with the wrong namespace: xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/".
By the way, readable('true') must be called after service().
Otherwise, the request XML is not readable.