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

邮差的信 提交于 2019-12-12 04:56:35

问题


I am a newbie to Perl programming.

In order to learn accessing a soap service, I tried to create a soap client that can connect to this in which I was successful to use the web service.

Now, I migrated my code to connect to my company's soap service but I encountered a problem.

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

See code snippet below.

#!/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);

Investigating it further why it won't work, I use a 3rd party software called .NET WebService Studio. I realize from the returned of the WebService Studio that my company's Soap service uses two WSDL file through WSDL:Import.

I would like to ask from this community of how I can modify my program in order to have access to company's soap service using WSDL11.

I have also attached the dumped data of the soap service connection as reference through print Dumper(\$SoapSrvc) statement.

Link: Dumped_SoapSrvc Data


回答1:


A cause can be that XML::Compile::WSDL11 doesn't load xsd's referenced from a wsdl file. You have to download your wsdl file. Read it to find references to external files like . Download referenced files check them for references... When you have everything you can use it like this:

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

It would be easier to diagnose the problem if you post the wsdl file.



来源:https://stackoverflow.com/questions/29554734/perl-wsdl11-cant-make-it-to-work-on-wsdl-with-xml-import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!