- 论坛徽章:
- 0
|
10可用积分
我用apache,配置了 perl的web services。
服务器端如下:
- #soap.cgi
- use warnings;
- use strict;
- use SOAP::Transport::HTTP;
- SOAP::Transport::HTTP::CGI
- -> dispatch_to('E:/www/WebServices/PM','Module::Name','Module::method')
- -> options({compress_threshold => 10000})
- -> handle
- ;
复制代码
这个cgi放在apache下的一个虚拟目录中,'E:/www/WebServices/PM' 下面为我自己写的pm包的总目录。
我在下面的客户端连接:
- use warnings;
- use strict;
- use SOAP::Lite;
- my $soap = SOAP::Lite
- -> uri('/examples/helloservice')
- -> proxy('http://192.168.200.2:8000/services/soap.cgi', timeout => 5);
- my $bb = $soap->sayHello("aa")->result();
- print " this is result : $bb \n";
复制代码
这个可以执行,也可以获得 examples::helloservice.pm 中的 sayHello的方法的数据。
我现在的问题是,想通过写WSDL来实现,
我写的WSDL如下:
- <definitions name="HelloService"
- targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl"
- xmlns="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <message name="SayHelloRequest">
- <part name="firstName" type="xsd:string"/>
- </message>
- <message name="SayHelloResponse">
- <part name="greeting" type="xsd:string"/>
- </message>
-
- <portType name="Hello_PortType">
- <operation name="sayHello">
- <input message="tns:SayHelloRequest"/>
- <output message="tns:SayHelloResponse"/>
- </operation>
- </portType>
-
- <binding name="Hello_Binding" type="tns:Hello_PortType">
- <soap:binding style="rpc"
- transport="http://schemas.xmlsoap.org/soap/http"/>
- <operation name="sayHello">
- <soap:operation soapAction="sayHello"/>
- <input>
- <soap:body
- encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- namespace="urn:examples:helloservice"
- use="encoded"/>
- </input>
- <output>
- <soap:body
- encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- namespace="urn:examples:helloservice"
- use="encoded"/>
- </output>
- </operation>
- </binding>
-
- <service name="Hello_Service">
- <documentation>WSDL File for HelloService</documentation>
- <port binding="tns:Hello_Binding" name="Hello_Port">
- <soap:address
- location="http://192.168.200.2:8000/services/soap.cgi"/>
- </port>
- </service>
- </definitions>
复制代码
我在客户端用: hello.pl
- use SOAP::Lite;
- print "Connecting to Hello Service...\n";
- my $soap = SOAP::Lite
- -> service('http://192.168.200.2:8000/wsdl/HelloService.wsdl');
- my $result = $soap->sayHello('aa');
- print $result->result();
复制代码
这样使用就有问题,大家帮我看看。
Connecting to Hello Service...
Can't call method "result" on an undefined value at hello.pl line 8.
搞了好久了,还是有问题。
多谢大家。
[ 本帖最后由 among29 于 2008-12-15 14:54 编辑 ] |
|