Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > 其他编程语言 > Writing a Client using SOAP
【标  题】:Writing a Client using SOAP
【关键字】:Writing,Client,using,SOAP
【来  源】:http://www.cublog.cn/u/19449/showart.php?id=118233

Writing a Client using SOAP

Your Ad Here

Writing a Client using SOAP::Lite for Perl

Writing a SOAP Client using the SOAP::Lite package for Perl is very simple. This tutorial walks you through a simple client that accesses the PING service hosted at http://www.xmethods.net

The following line imports the SOAP::Lite package for use by the client.

    use SOAP::Lite;
The following line executes the SOAP invocation in one easy step and sets the response object to $response :
    $response = SOAP::Lite
    -> proxy("http://services.xmethods.com/perl/soaplite.cgi")
    -> uri("urn:xmethodsPing")
    -> pingHost ("www.yahoo.com");

"Proxy" is the SOAP Endpoint
"URI" is the namespace identifier for the Interface / Object
"pingHost" is the method itself.
"www.yahoo.com" is the string argument for the pingHost method.

When this line is executed, the library encodes the method parameters by autodetecting type and assigning a system-generated name to this parameter (for basic types like "string" or "integer" , most server implementations ignore the input parameter names and just focus on the values, using parameter order as a way to map to service method arguments). If you want more control over the encoding process, you can use the following:

    pingHost ( SOAP::Data->name("Hostname")->value("www.yahoo.com")->type("string") );

Once the response object is created, you can check to see if a fault was returned:

    die "Fault: ".$response->faultcode." ".$response->faultdetail." ".$response->faultstring if $response->faultcode;

Otherwise, the result is stored in $response->result:

    print $response->result;
In the case of this example, because the PING service responds with a string, the returned value is a string.

If the response had been an array, the returned value would have been an array reference.
If the response had been a structure, the returned value would have been a hash reference.

As you can see, writing SOAP::Lite clients is very easy!

Perl::LWP::Demo::Put:【上一篇】
初探PEAR::MDB2:【下一篇】
【相关文章】
  • Using filemon for Detailed I/O Analysis
  • Using Raw Disk I/O
  • Using SDL Threads
  • Why are you using linux?
  • Essential Web Services: SOAP, WSDL, UDDI
  • 基于 SOAP 的 Web 服务中的复杂数据类型
  • Identifying P2P users using traffic analysis
  • Cannot view some web sites when using PPPoE
  • DB2 DBM中AUTHENTICATION参数为CLIENT时
  • POP3 Client ClassLibrary By .Net FrameWork 2.0
  • 【随机文章】
  • FreeHand 绘制鲜花(1)
  • yubinbin2002-07-31, 09:29 PM不太清楚,可能是软件自身的问题吧
  • 积少成多,收集网上ajax文章
  • 数字电视机顶盒之解决方案
  • 超级简单的发送邮件程序
  • modversions.h error
  • Intel平台下linux中 ELF文件动态链接的加载、解析及实例分析(二): 函数解析与卸载
  • [转载]jsp页面显示数据导出到excel表中
  • 在nant中改变编译的目标平台
  • 质量管理新理念——以员工为中心
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.