How to add an arbitrary field with XML :: Compile :: WSDL11 (error: tag `param 'is not used in ...)

I am trying to use a module XML::Compile::WSDL11to create a SOAP message in the base of a wsdl file. In the definitions of xsd there is a parameter called UserArea, which should contain arbitrary fields (extensions):

<xsd:element name="UserArea" type="UserAreaType"/>
<xsd:complexType name="UserAreaType">
  <xsd:sequence>
    <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

So, I can manually create a valid xml:

<ProcessAssessmentOrder>
  ...
  <DataArea>
   ...
   <AssessmentOrder>
     ...
     <UserArea xmlns:xxx="http://example.com">
        <xxx:someURL>http://someurl.example.com</xxx:someURL>
      </UserArea>
    </AssessmentOrder>
  </DataArea>
</ProcessAssessmentOrder>

This works and is being tested. However, trying to use XML::Compile::WSDL11, I got an error:

mistake: tag `xxx:SomeURL' not used at {http://www.hr-xml.org/3}ProcessAssessmentOrder/DataArea/AssessmentOrder/CustomerParty/PartyReportingIDs/UserArea

And the parameter is not in the generated xml.

So far, this is my Perl code:

use strict;
use warnings;

use DateTime;
use XML::Compile::Transport::SOAPHTTP;
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;

my %args = (
  releaseID => '3.3',
  ApplicationArea => {
    CreationDateTime => DateTime->now,
  },
  DataArea => {
    Process => {},
    AssessmentOrder => {
      UserArea => {
        'xxx:SomeURL' => 'www.example.com',
      },
    },
  },
);


my $wsdl_path = '/home/david/HR-XML-3_3/Assessments/org_hr-xml/3_3/WebServices/WSDL/AssessmentOrder.wsdl';
my $wsdl  = XML::Compile::WSDL11->new($wsdl_path);
import_definitions($wsdl, '/home/david/HR-XML-3_3/Assessments/');
$wsdl->compileCalls(
  port     => 'AssessmentOrder_Port',
  endpoint => 'http://127.0.0.1/xxx',
);

my($response, $trace) = $wsdl->call('ProcessAssessmentOrder', %args);

sub import_definitions { 
  my($wsdl, $path) = @_;
  opendir (my $dh, $path);
  while (my $file = readdir($dh)) {
    next if ($file eq '.' || $file eq '..');
    if (-d "$path/$file") {
      import_definitions($wsdl, "$path/$file");
    }
    elsif ($file =~ m#\.xsd$#) {
      $wsdl->importDefinitions("$path/$file");
    }
  }
  closedir($dh);
};

How to make it work to get xml with line

<xxx:someURL>http://someurl.example.com</xxx:someURL>

ยฟยท _ ยท?

+4
source share
2 answers

You can try adding:

my $myns = 'http://example.com';
$wsdl->prefixes => { $myns  => [ uri => $myns, prefix => 'xxx' ] };

seen at http://search.cpan.org/

0
0

Source: https://habr.com/ru/post/1544154/


All Articles