我已经创建了WSDL文件,并使用PERL soap方法连接该文件。执行后,我得到以下错误消息
“ 在/usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm 187行的第1行第1列字节1处格式不正确(无效令牌)。
”。请让我知道必须解决此问题。查看下面的源代码。
soap-client.pl
#!/usr/bin/perl -w
#use SOAP::Lite +trace => ‘debug’;
use SOAP::Lite;
my $client = SOAP::Lite
->service('http://localhost/soap/perl/marketplace.wsdl');
my $result = $client->login( 'test_user', 'test_password' );
#~ my $result = $client->sayHello('');
print $result;
soap-server.pl
#!/usr/bin/perl
function login( $login, $password )
{
return $login;
}
function doFilter( $params )
{
return "some string";
}
marketplace.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Marketplace"
targetNamespace="urn:Marketplace"
xmlns:tns="urn:Marketplace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="LoginRequest">
<part name="login" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="LoginResponse">
<part name="result" type="xsd:string"/>
</message>
<portType name="LoginPort">
<operation name="login">
<input message="tns:LoginRequest"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="LoginBinding" type="tns:LoginPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction="urn:LoginAction"/>
<input>
<soap:body use="encoded" namespace="urn:Marketplace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Marketplace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="WSDLService">
<port name="LoginPort" binding="tns:LoginBinding">
<soap:address location="http://localhost/soap/perl/soap-server.pl"/>
</port>
</service>
</definitions>
最终运行soap-client.pl文件,返回以下错误消息。
“ 在/usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm 187行的第1行第1列字节1处格式不正确(无效令牌)。
”。答案 0 :(得分:0)
取消注释#use SOAP :: Lite + trace =>'调试';行并查看产生的错误。