Javascript PhoneGap调用WSDL
我有一个调用WSDL Web服务的perl脚本,我尝试将其移植到JavaScript,但没有成功:( 我还需要向服务器进行身份验证以获得响应 我需要在我的电话缺口项目中使用这段代码。欢迎任何建议 perl脚本如下所示:Javascript PhoneGap调用WSDL,javascript,jquery,ajax,cordova,wsdl,Javascript,Jquery,Ajax,Cordova,Wsdl,我有一个调用WSDL Web服务的perl脚本,我尝试将其移植到JavaScript,但没有成功:( 我还需要向服务器进行身份验证以获得响应 我需要在我的电话缺口项目中使用这段代码。欢迎任何建议 perl脚本如下所示: my $url = "https://$user:$pass\@pathToMyExternalWSDL.xml?VERSION=1.1&STYLE=style"; my $soap = SOAP::Lite->serv
my $url = "https://$user:$pass\@pathToMyExternalWSDL.xml?VERSION=1.1&STYLE=style";
my $soap = SOAP::Lite->service($url)->autotype(1)->readable(1)->on_fault( sub
{
my $soap = shift;
my $res = shift;
if(ref($res) eq '')
{
warn ($res);
}
else
{
warn($res->faultstring);
}
return new SOAP::SOM;
});
sub SOAP::Transport::HTTP::Client::get_basic_credentials{return $user=>$pass;}
my $response = $soap->action($param1, $param2);
Accept: text/xml
Accept: multipart/ *
Accept: application/soap
Content-Length: 926
Content-Type: text/xml; charset=utf-8
SOAPAction: "action"
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<action>
<param1 xsi:type="data_type1">myParam1</param1>
<param2 xsi:type="data_type2">myParam2</param2>
</wc:action>
</soap:Body>
</soap:Envelope>
请求如下所示:
my $url = "https://$user:$pass\@pathToMyExternalWSDL.xml?VERSION=1.1&STYLE=style";
my $soap = SOAP::Lite->service($url)->autotype(1)->readable(1)->on_fault( sub
{
my $soap = shift;
my $res = shift;
if(ref($res) eq '')
{
warn ($res);
}
else
{
warn($res->faultstring);
}
return new SOAP::SOM;
});
sub SOAP::Transport::HTTP::Client::get_basic_credentials{return $user=>$pass;}
my $response = $soap->action($param1, $param2);
Accept: text/xml
Accept: multipart/ *
Accept: application/soap
Content-Length: 926
Content-Type: text/xml; charset=utf-8
SOAPAction: "action"
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<action>
<param1 xsi:type="data_type1">myParam1</param1>
<param2 xsi:type="data_type2">myParam2</param2>
</wc:action>
</soap:Body>
</soap:Envelope>
关于此错误的原因是浏览器中对跨域调用的限制。您只能回拨为您提供HTML/JavaScript的服务器 您需要一个支持JSONP的代理服务器或服务提供商来使用跨域服务