免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3018 | 回复: 3

使用SOAP::Lite调用web service问题 [复制链接]

论坛徽章:
0
发表于 2012-08-31 15:59 |显示全部楼层
使用soap:lite调用web服务,http报文正常,但是反回
  1. Not a HASH reference at /usr/local/lib/perl5/site_perl/5.16.1/SOAP/Lite.pm line 3828.
复制代码
请问是什么问题。

详细报文如下:

  1. [root@RHEL5 cgi-bin]# perl client.pl
  2. SOAP::Transport::new: ()
  3. SOAP::Serializer::new: ()
  4. SOAP::Deserializer::new: ()
  5. SOAP::Parser::new: ()
  6. SOAP::Lite::new: ()
  7. SOAP::Transport::HTTP::Client::new: ()
  8. SOAP::Lite::call: ()
  9. SOAP::Serializer::envelope: ()
  10. SOAP::Serializer::envelope: new 100
  11. SOAP::Data::new: ()
  12. SOAP::Data::new: ()
  13. SOAP::Data::new: ()
  14. SOAP::Data::new: ()
  15. SOAP::Data::new: ()
  16. SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0xb6df5c8)
  17. SOAP::Transport::HTTP::Client::send_receive: POST http://localhost/cgi-bin/sev.pl HTTP/1.1
  18. Accept: text/xml
  19. Accept: multipart/*
  20. Accept: application/soap
  21. Content-Length: 437
  22. Content-Type: text/xml; charset=utf-8
  23. SOAPAction: "World#new"

  24. <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><new xmlns="World"><c-gensym3 xsi:type="xsd:int">100</c-gensym3></new></soap:Body></soap:Envelope>
  25. SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0xb9840e0)
  26. SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
  27. Connection: close
  28. Date: Fri, 31 Aug 2012 09:27:01 GMT
  29. Server: Apache/2.2.22 (Unix) mod_perl/2.0.7 Perl/v5.16.1
  30. Content-Length: 551
  31. Content-Type: text/xml; charset=utf-8
  32. Client-Date: Fri, 31 Aug 2012 09:27:01 GMT
  33. Client-Peer: 127.0.0.1:80
  34. Client-Response-Num: 1
  35. SOAPServer: SOAP::Lite/Perl/0.715

  36. <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:namesp1="http://namespaces.soaplite.com/perl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><newResponse xmlns="World"><World xsi:type="namesp1:World"><_temperature xsi:type="xsd:int">100</_temperature></World></newResponse></soap:Body></soap:Envelope>
  37. SOAP::Deserializer::deserialize: ()
  38. SOAP::Parser::decode: ()
  39. SOAP::SOM::new: ()
  40. SOAP::SOM::DESTROY: ()
  41. SOAP::Lite::call: ()
  42. SOAP::Serializer::envelope: ()
  43. SOAP::Serializer::envelope: as_celsius World=HASH(0xbc4b570)
  44. SOAP::Data::new: ()
  45. SOAP::Data::new: ()
  46. SOAP::Data::DESTROY: ()
  47. SOAP::Data::DESTROY: ()
  48. SOAP::Data::DESTROY: ()
  49. SOAP::Data::DESTROY: ()
  50. SOAP::Data::DESTROY: ()
  51. SOAP::Data::new: ()
  52. SOAP::Data::new: ()
  53. SOAP::Data::new: ()
  54. SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0xbc52d88)
  55. SOAP::Transport::HTTP::Client::send_receive: POST http://localhost/cgi-bin/sev.pl HTTP/1.1
  56. Accept: text/xml
  57. Accept: multipart/*
  58. Accept: application/soap
  59. Content-Length: 549
  60. Content-Type: text/xml; charset=utf-8
  61. SOAPAction: "World#as_celsius"

  62. <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:namesp1="http://namespaces.soaplite.com/perl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><as_celsius xmlns="World"><World xsi:type="namesp1:World"><_temperature xsi:type="xsd:int">100</_temperature></World></as_celsius></soap:Body></soap:Envelope>
  63. SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0xbc53d10)
  64. SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
  65. Connection: close
  66. Date: Fri, 31 Aug 2012 09:27:01 GMT
  67. Server: Apache/2.2.22 (Unix) mod_perl/2.0.7 Perl/v5.16.1
  68. Content-Length: 722
  69. Content-Type: text/xml; charset=utf-8
  70. Client-Date: Fri, 31 Aug 2012 09:27:02 GMT
  71. Client-Peer: 127.0.0.1:80
  72. Client-Response-Num: 1
  73. SOAPServer: SOAP::Lite/Perl/0.715

  74. <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:namesp2="http://namespaces.soaplite.com/perl" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><namesp1:World xmlns:namesp1="http://namespaces.soaplite.com/header" xsi:type="namesp2:World"><_temperature xsi:type="xsd:int">100</_temperature></namesp1:World></soap:Header><soap:Body><as_celsiusResponse xmlns="World"><s-gensym5 xsi:type="xsd:float">37.7777777777778</s-gensym5></as_celsiusResponse></soap:Body></soap:Envelope>
  75. SOAP::Deserializer::deserialize: ()
  76. SOAP::Parser::decode: ()
  77. SOAP::SOM::new: ()
  78. SOAP::Data::new: ()
  79. SOAP::Data::new: ()
  80. SOAP::Data::new: ()
  81. Not a HASH reference at /usr/local/lib/perl5/site_perl/5.16.1/SOAP/Lite.pm line 3828.
  82. SOAP::SOM::DESTROY: ()
  83. SOAP::Lite::DESTROY: ()
  84. SOAP::Deserializer::DESTROY: ()
  85. SOAP::Parser::DESTROY: ()
  86. SOAP::Transport::DESTROY: ()
  87. SOAP::Transport::HTTP::Client::DESTROY: ()
  88. SOAP::Serializer::DESTROY: ()
  89. SOAP::Data::DESTROY: ()
  90. SOAP::Data::DESTROY: ()
  91. SOAP::Data::DESTROY: ()
  92. SOAP::Data::DESTROY: ()
  93. SOAP::Data::DESTROY: ()
  94. SOAP::Data::DESTROY: ()
  95. SOAP::Data::DESTROY: ()
  96. SOAP::Data::DESTROY: ()
  97. [root@RHEL5 cgi-bin]#
复制代码
client代码如下:

  1. #!/usr/local/bin/perl
  2. use SOAP::Lite +trace;
  3. my $soap = SOAP::Lite                                 
  4.     -> uri('World')
  5.     -> proxy('http://localhost/cgi-bin/sev.pl');
  6.   my $temperatures = $soap                              
  7.     -> call(new => 100) # accept Fahrenheits            
  8.     -> result;                                          
  9.   print $soap                                          
  10.     -> as_celsius($temperatures)                        
  11.     -> result;   
复制代码
servcie代码如下:

  1. #!/usr/local/bin/perl
  2. use strict;
  3. use warnings;
  4. package World;
  5.    
  6. sub new {
  7.     my $self = shift;
  8.     my $class = ref($self) || $self;
  9.     bless {_temperature => shift} => $class;
  10. }
  11. sub as_fahrenheit {
  12.     return shift->{_temperature};
  13. }
  14. sub as_celsius {
  15.     return 5/9*(shift->{_temperature}-32);
  16. }
复制代码

论坛徽章:
0
发表于 2012-09-03 11:35 |显示全部楼层
  有没有人知道啥原因啊?

论坛徽章:
46
15-16赛季CBA联赛之四川
日期:2018-03-27 11:59:132015年亚洲杯之沙特阿拉伯
日期:2015-04-11 17:31:45天蝎座
日期:2015-03-25 16:56:49双鱼座
日期:2015-03-25 16:56:30摩羯座
日期:2015-03-25 16:56:09巳蛇
日期:2015-03-25 16:55:30卯兔
日期:2015-03-25 16:54:29子鼠
日期:2015-03-25 16:53:59申猴
日期:2015-03-25 16:53:29寅虎
日期:2015-03-25 16:52:29羊年新春福章
日期:2015-03-25 16:51:212015亚冠之布里斯班狮吼
日期:2015-07-13 10:44:56
发表于 2012-09-03 12:31 |显示全部楼层
这个太细节了你看下是不是有什么需要检查的异常没处理的,不会这个,实在没那个精力给你一级一级查看
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP