Perl WSDL11 无法通过 XML 导入在 WSDL 上工作

Perl WSDL11 Can't Make it to Work on WSDL with XML import

我是 Perl 编程的新手。

为了学习访问 soap 服务,我尝试创建一个可以连接到 this 的 soap 客户端,我在其中成功使用了 web 服务。

现在,我迁移了我的代码以连接到我公司的 soap 服务,但我遇到了问题。

"The error says that their were no port_type and no operation as well."

请参阅下面的代码片段。

#!/usr/bin/perl

use 5.018;
use strict;
use warnings;

use Data::Dumper qw{Dumper};
use XML::Compile::SOAP11;
use XML::Compile::SOAP12;
use XML::Compile::WSDL11;

my $WsdlUrl;
my $WsdlXml;
my $SoapSrvc;
my (%SoapOps);

$WsdlUrl = "http://maxcavmes04/CamstarExternal/camstar.svc";
$WsdlXml = XML::LibXML->new->parse_file($WsdlUrl);
$SoapSrvc = XML::Compile::WSDL11->new($WsdlXml);

print Dumper($SoapSrvc);

foreach my $SoapOp ($SoapSrvc->operations())
{
    # XML::Compile::SOAP 2.x
    if ($XML::Compile::SOAP::VERSION > 1.99)
    {
        $SoapOps{$SoapOp->name} 
            = $SoapSrvc->compileClient(operation => $SoapOp->name,
                                       port => SOAP_PORT_TYPE);
    }
    else  # XML::Compile::SOAP 0.7x
    {
        $SoapOps{$SoapOp->{operation}} 
            =  $SoapSrvc->compileClient(operation => $SoapOp->{operation},
                                        port => SOAP_PORT_TYPE);
    }
}

print "\n\n";
exit(0);

为了进一步调查它为什么不起作用,我使用了一个名为 .NET WebService Studio 的第三方软件。我从 WebService Studio 的返回中意识到我公司的 Soap 服务通过 WSDL:Import.

使用两个 WSDL 文件

我想从这个社区询问如何修改我的程序,以便使用 WSDL11 访问公司的 soap 服务。

我还通过 print Dumper($SoapSrvc) 语句附加了 soap 服务连接的转储数据作为参考。

Link: Dumped_SoapSrvc Data

原因可能是 XML::Compile::WSDL11 没有加载从 wsdl 文件引用的 xsd。您必须下载 wsdl 文件。阅读它以查找对外部文件的引用,例如 .下载参考文件检查它们的参考...当你拥有一切时,你可以像这样使用它:

my $wsdl = XML::Compile::WSDL11->new();
$wsdl->importDefinitions("first.xsd");
$wsdl->importDefinitions("second.xsd");
$wsdl->addWSDL("my_service.wsdl");

如果您 post wsdl 文件,诊断问题会更容易。