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

What's wrong? or an example wsdl for Perl WS server?

Expand Messages
  • pig_valley2000
    Hi, I need to write a web service server in Perl, and the client will be in Java. I first tried with a simple example from Web
    Message 1 of 1 , Oct 27, 2004
    • 0 Attachment
      Hi,

      I need to write a web service server in Perl, and the client will be
      in Java.

      I first tried with a simple example from Web
      http://www.sdc.iup.edu/outreach/spring2002/webservices/perlserver.html

      The server code is:

      use SOAP::Transport::HTTP;
      SOAP::Transport::HTTP::CGI->dispatch_to('RiverGauge')->handle;

      package RiverGauge;
      sub getRiverGauge {
      shift; # skip package name;
      my ($canoeTripNumber) = shift; # get canoe trip number
      my ($r) = $canoeTripNumber * 0.11;
      return $r;
      }

      ************

      The wsdl is:

      <?xml version="1.0"?>
      <definitions name="rivergauge"
      targetNamespace="http://...../rivergauge_cgi.wsdl"
      xmlns:tns="http://...../rivergauge_cgi.wsdl"
      xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns="http://schemas.xmlsoap.org/wsdl/">

      <!-- Data Types -->
      <message name="getRiverGaugeInput">
      <part name="canoeTripNumber" element="xsd:int"/>
      </message>

      <message name="getRiverGaugeOutput">
      <part name="return" type="xsd:float"/>
      </message>

      <!-- Interface -->
      <portType name="rivergaugePortType">
      <operation name="getRiverGauge">
      <input message="tns:getRiverGaugeInput"/>
      <output message="tns:getRiverGaugeOutput"/>
      </operation>
      </portType>

      <!-- Implementation -->
      <binding name="rivergaugeSoapBinding" type="tns:rivergaugePortType">
      <soap:binding style="rpc"
      transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="getRiverGauge">
      <soap:operation soapAction="http://.../cgi-bin/rivergauge.cgi"/>
      <input>
      <soap:body use="encoded"

      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
      <soap:body use="encoded"

      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
      </operation>>
      </binding>

      <!-- Service -->
      <service name="rivergaugeService">
      <documentation>This service delivers the stream gauge stage for a
      given
      canoe trip ID.</documentation>
      <port name="rivergaugePort" binding="tns:rivergaugeSoapBinding">
      <soap:address location="http://.../cgi-bin/rivergauge.cgi"/>
      </port>
      </service>
      </definitions>

      ****************

      The client is:

      #! /local/bin/perl

      use SOAP::Lite;

      my $trip = 12;
      print "\n\nThe stream gauge $trip is ";
      print SOAP::Lite
      -> service('http://...../rivergauge_cgi.wsdl')
      -> getRiverGauge($trip);

      print " feet.\n\n";

      ******************

      The result is (no error reported):

      ... 746% ./rivergauge_cgi_wsdl.pl


      The stream gauge 12 is feet.

      **********************

      Using uri and proxy with client, it will give correct answer. Could
      someone tell what's wrong here?
    Your message has been successfully submitted and would be delivered to recipients shortly.