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

Denied access to method error

Expand Messages
  • aviannachao
    Hi all, I made a simple hello world web service, and a corresponding WSDL page. #HelloWorld.pl use SOAP::Transport::HTTP; use HelloWorld;
    Message 1 of 1 , Sep 3, 2004
    View Source
    • 0 Attachment
      Hi all,

      I made a simple hello world web service, and a corresponding WSDL page.

      #HelloWorld.pl
      use SOAP::Transport::HTTP;
      use HelloWorld;

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

      #HelloWorld.pm
      package HelloWorld;

      sub sayHello {
      return "Yo you there! ".$_[1];
      }

      1;

      I put this web service on my local machine, and have no problems
      accessing it via direct Perl invocation, with or without autodispatch,
      ie:

      # with autodispatch, works fine
      use SOAP::Lite +autodispatch =>
      uri => 'HelloWorld',
      proxy => 'http://localhost/soaptest/HelloWorld.pl';

      my $a=HelloWorld->sayHello('Avianna');
      print $a;

      # without autodispatch, also works fine
      use SOAP::Lite +trace;

      print SOAP::Lite
      -> uri('HelloWorld')
      -> proxy('http://localhost/soaptest/HelloWorld.pl')
      -> sayHello('Avianna')
      -> result;

      However, when I try to access the web service via the WSDL page, I get
      an error.

      #HelloWorld.wsdl
      <?xml version="1.0"?>
      <definitions name="HelloWorld"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      targetNamespace="http://localhost/soaptest/HelloWorld.wsdl"
      xmlns:tns="http://localhost/soaptest/HelloWorld.wsdl"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsdl="http://www.w3.org/2001/XMLSchema">
      <types>
      <xsd:schema targetNamespace="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="sayHelloRequest" type="xsd:string" />
      <xsd:element name="sayHelloResponse" type="xsd:string" />
      </xsd:schema>
      </types>
      <message name="sayHelloRequest">
      <part name="sayHelloRequestSoapMsg" element="xsdl:sayHelloRequest"/>
      </message>
      <message name="sayHelloResponse">
      <part name="sayHelloResponseSoapMsg" element="xsdl:sayHelloResponse"/>
      </message>
      <portType name="HelloWorldPortType">
      <operation name="sayHello">
      <input message="tns:sayHelloRequest" />
      <output message="tns:sayHelloResponse" />
      </operation>
      </portType>
      <binding name="HelloWorldBinding" type="tns:HelloWorldPortType">
      <soap:binding style="document"
      transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sayHello">
      <soap:operation style="document" soapAction=""/>
      <input>
      <soap:body use="literal"/>
      </input>
      <output>
      <soap:body use="literal"/>
      </output>
      </operation>
      </binding>
      <service name="HelloWorld">
      <documentation>
      Test HelloWorld web service
      </documentation>
      <port name="HelloWorldPort" binding="tns:HelloWorldBinding">
      <soap:address location="http://localhost/soaptest/HelloWorld.pl"/>
      </port>
      </service>
      </definitions>

      #hello_wsdl.pl
      use SOAP::Lite +trace;

      my $g = SOAP::Lite
      ->service('http://localhost/soaptest/HelloWorld.wsdl')
      ->sayHello('Avianna');

      print $g;

      hello_wsdl.pl output:

      Denied access to method (sayHello) in class (main) at
      C:/Perl/site/lib/SOAP/Lite.pm line 2159

      What is causing this?? Is this a problem with my WSDL page? I did 2
      versions, one was hand coded, pretty much copying the example from the
      Programming Web Services with Perl book, and the one above was
      generated using the WSDL::Generator module. The WSDL pages are very
      similar except the WSDL page from the book uses binding style=rpc and
      the one generated from WSDL::Generator uses style=document.

      Any ideas would be appreciated.

      Thanks in advance.
    Your message has been successfully submitted and would be delivered to recipients shortly.