Loading ...
Sorry, an error occurred while loading the content.

1064Re: WSDL not working with 0.52

Expand Messages
  • markbaxterus@yahoo.com
    Nov 30, 2001
    • 0 Attachment
      Hello,

      In partial answer to my own question, I did find a very similar post
      in #668. I think that this is the same issue (in my case, the "tns"
      namespace is not defined in the request).

      I think that I'm very close to "fixing" the WSDL, but I'm not quite
      getting things defined properly. Might someone be able to suggest
      how I might alter the wsdl, in order to get "tns" properly represented
      in the request?

      Any suggestions would be much appreciated.

      Thanks in advance,

      Mark

      - - - - - - - - - - - - - - - - - -

      the relevant "type" from the wsdl:

      xmlns:tns='http://demo.com/SqrtDemo/service'
      ...
      <xsd:schema targetNamespace="http://demo.com/SqrtDemo/service">
      <xsd:complexType name="SqrtRequest">
      <xsd:sequence>
      <xsd:element name="num" type="xsd:double"/>
      <xsd:element name="name" type="xsd:string"/>
      </xsd:sequence>
      <xsd:complexType name="SqrtResponse">
      <xsd:sequence>
      <xsd:element name="error_msg" type="xsd:string"/>
      <xsd:element name="sqrt" type="xsd:double"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:schema>

      the messages:

      <wsdl:message name='SqrtDemo_getSqrt_Request'>
      <wsdl:part name='p0' type='tns:SqrtRequest'/>
      </wsdl:message>
      <wsdl:message name='SqrtDemo_getSqrt_Response'>
      <wsdl:part name='response' type='tns:SqrtResponse'/>
      </wsdl:message>

      --- In soaplite@y..., markbaxterus@y... wrote:
      > Hi,
      >
      > When using SOAP::Lite 0.52, I find that my WSDL files can no longer
      be
      > used (it worked fine with SOAP::Lite 0.50).
      >
      > The error I get with 0.52 is:
      >
      > FAULT(sqrtdemo line 80): SOAP-ENV:Client, Application failed
      during
      > request deserialization: Unresolved prefix 'tns' for attribute
      > value 'tns:SqrtRequest'
      >
      > Any ideas why the WSDL does not work with 0.52?
      >
      > Thanks,
      >
      > Mark
      >
      > P.S. Attachments below include:
      >
      > - The WSDL file (SqrtDemoService.wsdl)
      > - A SOAP::Lite client script (sqrtdemo)
      > - A SOAP::Lite server CGI (sqrtdemo.cgi)
      >
      > A typical sqrtdemo usage that inspires the FAULT:
      >
      > % sqrtdemo -s 42 -w file:./SqrtDemoService.wsdl
      >
      >
      > The WSDL file I am using:
      > ---< snip >---------------------------------------------------------
      > <?xml version='1.0'?>
      > <wsdl:definitions name='SqrtDemo'
      > targetNamespace='http://demo.com/SqrtDemo/service'
      > xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
      > xmlns:xsd='http://www.w3.org/2001/XMLSchema'
      > xmlns:tns='http://demo.com/SqrtDemo/service'
      > xmlns:http='http://schemas.xmlsoap.org/wsdl/http/'
      > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
      > xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/'
      > xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
      > xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'>
      > <wsdl:types>
      > <xsd:schema
      > targetNamespace="http://demo.com/SqrtDemo/service">
      > <xsd:complexType name="SqrtRequest">
      > <xsd:sequence>
      > <xsd:element name="num" type="xsd:double"/>
      > <xsd:element name="name" type="xsd:string"/>
      > </xsd:sequence>
      > </xsd:complexType>
      > <xsd:complexType name="SqrtResponse">
      > <xsd:sequence>
      > <xsd:element name="error_msg"
      type="xsd:string"/>
      > <xsd:element name="sqrt" type="xsd:double"/>
      > </xsd:sequence>
      > </xsd:complexType>
      > </xsd:schema>
      > </wsdl:types>
      > <wsdl:message name='SqrtDemo_getSqrt_Request'>
      > <wsdl:part name='p0' type='tns:SqrtRequest'/>
      > </wsdl:message>
      > <wsdl:message name='SqrtDemo_getSqrt_Response'>
      > <wsdl:part name='response' type='tns:SqrtResponse'/>
      > </wsdl:message>
      >
      > <wsdl:portType name='SqrtDemo'>
      > <wsdl:operation name='getSqrt' parameterOrder='p0'>
      > <wsdl:input name='getSqrt'
      > message='tns:SqrtDemo_getSqrt_Request'/>
      > <wsdl:output name='getSqrt'
      > message='tns:SqrtDemo_getSqrt_Response'/>
      > </wsdl:operation>
      > </wsdl:portType>
      >
      > <wsdl:binding name='SqrtDemo' type='tns:SqrtDemo'>
      > <soap:binding
      transport='http://schemas.xmlsoap.org/soap/http'
      > style='rpc'/>
      >
      > <wsdl:operation name='getSqrt'>
      > <soap:operation soapAction='urn:SqrtDemoService#getSqrt'
      > style='rpc'/>
      > <wsdl:input name='getSqrt'>
      > <soap:body
      > use='encoded'
      >
      > encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
      > namespace='urn:SqrtDemoService'
      > />
      > </wsdl:input>
      > <wsdl:output name='getSqrt'>
      > <soap:body
      > use='encoded'
      >
      > encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
      > namespace='urn:SqrtDemoService'
      > />
      > </wsdl:output>
      > </wsdl:operation>
      >
      > </wsdl:binding>
      >
      > <wsdl:service name='SqrtDemoService'>
      > <wsdl:port name='SqrtDemo' binding='tns:SqrtDemo'>
      > <soap:address
      >
      location='http://localhost:9014/cgi-bin/sqrtdemo.cgi'
      > />
      > </wsdl:port>
      > </wsdl:service>
      >
      > </wsdl:definitions>
      > ---< snip >---------------------------------------------------------
      >
      >
      > The SOAP::Lite client:
      > ---< snip >---------------------------------------------------------
      > #!/opt/third-party/bin/perl -w
      > #
      > # File: sqrtdemo
      > #
      > # A simple SOAP-based client to access the SqrtDemoService
      > # methods via the perl sqrtdemo.cgi script.
      > # Exercises:
      > #
      > # SqrtDemoService::getSqrt - calculate square root
      > #
      >
      > use strict;
      >
      > use File::Basename;
      > use Getopt::Long;
      > use IO::Handle;
      >
      > # Comment out the line below to get the default 0.50 SOAP::Lite.
      > use lib "/home/mbaxter/local/SOAP-Lite-0.52/lib";
      >
      > use SOAP::Lite;
      > ##use SOAP::Lite +'trace'; # uncomment to see everything.
      >
      > STDOUT->autoflush(1);
      >
      > my $URI = "urn:SqrtDemoService";
      > my $PROXY = ("http://localhost:9014/cgi-bin/sqrtdemo.cgi");
      >
      > my $sqrt_list;
      > my $name = "default-name";
      > my $wsdl;
      > my $uri;
      > my $proxy;
      > my $help;
      >
      > GetOptions(
      > "sqrt=s" => \$sqrt_list,
      > "name=s" => \$name,
      > "wsdl=s" => \$wsdl,
      > "uri=s" => \$uri,
      > "proxy=s" => \$proxy,
      > "help" => \$help
      > );
      >
      > usage() if $help;
      >
      > # Setup the sqrt demo service soap request object.
      > my $soap;
      > if ($wsdl) {
      > my $warning_orig = $^W;
      > $^W = 0; # the service call is not -w friendly.
      > $soap = SOAP::Lite->service($wsdl);
      > $^W = $warning_orig;
      > print("\n" .
      > "Using service description file: $wsdl\n");
      > } else {
      > $URI = $uri if $uri;
      > $PROXY = $proxy if $proxy;
      > $soap = SOAP::Lite
      > -> uri($URI)
      > -> proxy($PROXY);
      >
      > print("\n" .
      > "Using SOAP::Lite object calls via: \n" .
      > " uri = $URI\n" .
      > " proxy = $PROXY\n");
      > }
      >
      > if ($sqrt_list) {
      > # we have a comma seperated list of numbers that need square
      > roots.
      > my @numbers = split /,/, $sqrt_list;
      > print "\n";
      >
      > foreach my $num (@numbers) {
      > printf "[$name] Square root of %-11s: ", $num;
      > my $request = {
      > 'num' => $num,
      > 'name' => $name,
      > };
      > my $result = get_sqrt($request);
      > if ($result) {
      > if ($result->{fErrorMessage}) {
      > print $result->{fErrorMessage}, "\n";
      > } else {
      > printf "%.5f\n", $result->{'fSqrt'};
      > }
      > } else {
      > print "\nShould have received a fault...\n";
      > }
      > }
      > }
      >
      > print "\n";
      > exit 0;
      >
      >
      #-------------------------------------------------------------------------
      > # The low-level SOAP request routines. Just get the results from
      the
      > # SOAP server, and return the results (without interpretation). If
      > # there is a SOAP fault detected, return undef.
      >
      #-------------------------------------------------------------------------
      >
      > # N.B. A service description (WSDL) method call returns a "raw"
      result
      > # only, which we discard, since we really want the SOM object (so
      that
      > # we also have access to Fault info). After a WSDL method call, we
      > # get at the SOM object via the $soap->call. See:
      > # http://groups.yahoo.com/group/soaplite/message/975
      > #
      > # The "standard" uri/proxy method call does return a SOM object
      > directly.
      >
      > sub get_sqrt {
      > my $request = shift;
      >
      > my $som;
      > if ($wsdl) {
      > $soap->getSqrt($request);
      > $som = $soap->call;
      > } else {
      > $som = $soap->getSqrt($request);
      > }
      >
      > if ($som->fault) {
      > my ($packag, $filename, $line) = caller(0);
      > my $from = "$filename line $line";
      > print("FAULT($from): ", join ', ', $som->faultcode,
      > $som->faultstring);
      > return;
      > } else {
      > return $som->result;
      > }
      > }
      >
      >
      #-------------------------------------------------------------------------
      > # General purpose subroutines
      >
      #-------------------------------------------------------------------------
      >
      > sub usage {
      > my $prog = basename($0);
      >
      > print <<EOT;
      >
      > Usage $prog [options]
      >
      > Where options are:
      >
      > --sqrt=<csl> Comma seperated list of numbers for square
      > root.
      > --name=<name> Name for call.
      > --wsdl=<uri> Optional service description file. If set,
      > this
      > will override the default uri and proxy of:
      >
      > uri = $URI
      > proxy = $PROXY
      >
      > --uri=<uri> Override default uri.
      > --proxy=<proxy> Override default proxy.
      >
      > Examples:
      >
      > # get the square root of a couple of numbers
      > $prog -s 1234,-27 -name mark
      >
      > # get the square root and use a wsdl file
      > $prog -s 42 -name mark -w file:./SqrtDemoService.wsdl
      >
      > # generate a purposely bogus request, to generate a soap fault
      > $prog -s 42 -name dude
      >
      > EOT
      >
      > exit 1;
      > }
      > ---< snip >---------------------------------------------------------
      >
      > The SOAP::Lite server:
      > ---< snip >---------------------------------------------------------
      > #!/opt/third-party/bin/perl -w
      > #
      > # File: sqrtdemo.cgi
      > #
      > # A simple test/development perl SOAP server for SqrtDemoService.
      > # Handles calls to:
      > #
      > # SqrtDemoService::getSqrt - calculate square root
      > #
      > # Special features:
      > #
      > # - Calling getSqrt with an "name" of "dude" will generate a
      > fault.
      >
      > # Comment out the line below to get the default 0.50 SOAP::Lite.
      > use lib "/home/mbaxter/local/SOAP-Lite-0.52/lib";
      >
      > use strict;
      > use SOAP::Transport::HTTP;
      > $|++;
      >
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to('SqrtDemoService')
      > -> handle;
      >
      > package SqrtDemoService;
      >
      > sub getSqrt {
      > my $class = shift;
      > my $request = shift;
      >
      > my $num = $request->{num};
      > my $name = $request->{name};
      >
      > my %response = ();
      > $response{'fSqrt'} = 0.0;
      > $response{'fErrorMessage'} = "";
      >
      > if ($name eq "dude") {
      > # Generate a fault on demand.
      > die SOAP::Fault->faultcode('SqrtDemoService.Input')
      > ->faultstring('No square root for name="dude"');
      > }
      >
      > if ($num < 0.0) {
      > $response{'fErrorMessage'} =
      > "ERROR: no sqrt for negative: $num";
      > return \%response;
      > }
      >
      > $response{'fSqrt'} = sqrt $num;
      >
      > return \%response;
      > }
      > ---< snip >---------------------------------------------------------
    • Show all 2 messages in this topic