4

我需要使用 Perl 进行一些复杂的肥皂查询,最好使用SOAP::Lite. 我知道该服务处于活动状态,并且已成功从另一端获取错误。这是我需要做的肥皂查询:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <GetCategories xmlns="http://webservices.uship.com">
        <token>string</token>
    </GetCategories>
</soap:Body>
</soap:Envelope>

我通过谷歌对此进行了研究,但无济于事。

更新:到目前为止使用的代码是

use SOAP::Lite; 
print SOAP::Lite
 -> uri('webservices.uship.com/uShipsvc.asmx?WSDL';)
 -> proxy('http:/webservices.uship.com')
 -> GetCategories('myToken')
 -> result;

这返回

500 bad hostname, 500 Can't connect to :80 (Bad hostname '') at soap2.pl 第 2 行

4

4 回答 4

3

从 SOAP::Lite 的入门指南中,您的代码应类似于:

#!perl -w
use SOAP::Lite;
print SOAP::Lite                                            
  uri('http://www.soaplite.com/Temperatures')
  proxy('http://webservices.uship.com')
  GetCategories('string')
  result;

将返回对象的 URI 插入到uri()

于 2011-04-12T16:42:08.537 回答
1

我在进行 SOAP 调用时遇到问题,因为我正在与之交谈的服务器是 .NET,它显然与 SOAP::Lite 存在通信问题:http: //msdn.microsoft.com/en-us/library/ms995764.aspx#soapliteperl_topic3

即使您的服务器不是 .NET,这也是拨打电话的另一种方式(对我有用):

# proxy and uri strings should NOT have trialing slashes
my $_uri = 'http://youruri.com/whatever';
my $_proxy = 'http://yourproxy.com/something.asmx';
my $methodName = 'GetCategories';
my @params = (
        SOAP::Data->name( 'token'=>'string' ),
);

my $handle = SOAP::Lite
    ->uri( $_uri )
    ->proxy( $_proxy , timeout => 30, keep_alive => 1 )
    ->on_action( sub{ $_uri . "/" . $_[1] } );
my $method = SOAP::Data
    ->name( $methodName )
    ->attr( {xmlns => $_uri . "/"} );
my $rv = $handle->call( $method=>@params );
if( $rv->fault() ){
    print "SOAP Error ($methodName) :: " . $handle->transport()->status() . "\n\t" . $rv->faultcode() . ": " . $rv->faultstring();
} else {
    print $rv->result();
}

另外,查看您对其中一个答案的评论

代码使用 SOAP::Lite;打印 SOAP::Lite -> uri('webservices.uship.com/uShipsvc.asmx?WSDL';) -> proxy('http:/webservices.uship.com') -> GetCategories('myToken') -> 结果;

您可能将 uri 和代理向后。即,代理应该是您的.asmx(没有“?WSDL”)。如果您想要 ?WSDL,它是一种与使用 uri+proxy 完全不同的连接方法。见: http: //guide.soaplite.com/#access%20with%20service%20description%20%28wsdl%29

于 2011-07-28T14:33:35.553 回答
1

您需要更正您的 URI,http:/webservices.uship.com我得到500 No Host option provided at test-soap.pl line 7. 将其更改为:

use SOAP::Lite; 
print SOAP::Lite
 -> uri('http://webservices.uship.com/uShipsvc.asmx?WSDL')
 -> proxy('http://webservices.uship.com')
 -> GetCategories('myToken')
 -> result;
于 2012-12-19T22:05:03.817 回答
0

考虑使用SOAP::Trace来跟踪SOAP调用的执行

你可以在你的 lib/script 中包含这个 use 语句:

use SOAP::Lite +trace => [qw/ debug method fault /];

这可以帮助您调试SOAP呼叫。

于 2012-04-24T23:22:23.300 回答