简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM