免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2873 | 回复: 1
打印 上一主题 下一主题

perl web services 的WSDL问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-15 14:53 |只看该作者 |倒序浏览
10可用积分
我用apache,配置了 perl的web services。

服务器端如下:
  1. #soap.cgi
  2. use warnings;
  3. use strict;
  4. use SOAP::Transport::HTTP;

  5. SOAP::Transport::HTTP::CGI
  6.         -> dispatch_to('E:/www/WebServices/PM','Module::Name','Module::method')
  7.         -> options({compress_threshold => 10000})
  8.         -> handle
  9. ;
复制代码


这个cgi放在apache下的一个虚拟目录中,'E:/www/WebServices/PM' 下面为我自己写的pm包的总目录。

我在下面的客户端连接:
  1. use warnings;
  2. use strict;
  3. use SOAP::Lite;

  4. my $soap = SOAP::Lite
  5.         -> uri('/examples/helloservice')
  6.         -> proxy('http://192.168.200.2:8000/services/soap.cgi', timeout => 5);

  7. my $bb = $soap->sayHello("aa")->result();

  8. print " this is result : $bb \n";
复制代码


这个可以执行,也可以获得 examples::helloservice.pm 中的 sayHello的方法的数据。


我现在的问题是,想通过写WSDL来实现,
我写的WSDL如下:
  1. <definitions name="HelloService"
  2.    targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl"
  3.    xmlns="http://schemas.xmlsoap.org/wsdl/"
  4.    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  5.    xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl"
  6.    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  7.    <message name="SayHelloRequest">
  8.       <part name="firstName" type="xsd:string"/>
  9.    </message>
  10.    <message name="SayHelloResponse">
  11.       <part name="greeting" type="xsd:string"/>
  12.    </message>

  13.    <portType name="Hello_PortType">
  14.       <operation name="sayHello">
  15.          <input message="tns:SayHelloRequest"/>
  16.          <output message="tns:SayHelloResponse"/>
  17.       </operation>
  18.    </portType>
  19.    
  20.    <binding name="Hello_Binding" type="tns:Hello_PortType">
  21.       <soap:binding style="rpc"
  22.          transport="http://schemas.xmlsoap.org/soap/http"/>
  23.       <operation name="sayHello">
  24.          <soap:operation soapAction="sayHello"/>
  25.          <input>
  26.             <soap:body
  27.                encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  28.                namespace="urn:examples:helloservice"
  29.                use="encoded"/>
  30.          </input>
  31.          <output>
  32.             <soap:body
  33.                encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  34.                namespace="urn:examples:helloservice"
  35.                use="encoded"/>
  36.          </output>
  37.       </operation>
  38.    </binding>

  39.    <service name="Hello_Service">
  40.       <documentation>WSDL File for HelloService</documentation>
  41.       <port binding="tns:Hello_Binding" name="Hello_Port">
  42.          <soap:address
  43.             location="http://192.168.200.2:8000/services/soap.cgi"/>
  44.       </port>
  45.    </service>
  46. </definitions>
复制代码


我在客户端用: hello.pl
  1. use SOAP::Lite;
  2. print "Connecting to Hello Service...\n";
  3. my $soap =  SOAP::Lite
  4.    -> service('http://192.168.200.2:8000/wsdl/HelloService.wsdl');

  5. my $result = $soap->sayHello('aa');

  6. 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 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-12-15 16:30 |只看该作者
通过WSDL的话,客户端的写法应该不同吧?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP