频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

利用PocketSOAP链接webservice(1)---.net

来源: 作者: 出处:巧巧读书 2006-09-18 进入讨论组
QQRead:http://www.qqread.com/xml-soap/k234446.html

  PocketSOAP
This is a SOAP client COM component for the Windows family, originally targeted at PocketPC (hence the name), there is also a Win32 version that works on Windows 95/98/Me/NT4/2000/XP. The package includes a HTTP transport for making HTTP based SOAP requests, however the transport is separate from the main SOAP core, so any other transports can be easily added. James Clark's Excellent Expat XML Parser is used for parsing the response SOAP messages.
如果你想执行文章中给出了代码你需要下载并安装pocketsoap
至于如何建立webservice我就不费力气讲了,今天的主要目的是如何利用pocketsoap使一些事情变得简单。
1.在.net中使用PocketSOAP
如果在安装PocketSoap的过程中是根据系统默认选项的话那么在“c:\program files\simonfell\pocketSOAP1.2\”中你就会发现psoap32.dll文件
我们需要导入这个PocketSOAP NAMESPACE
例如:
using PocketSOAP;using System;public class test{    public static void Main(string[] args)    {        Console.WriteLine("Starting C# PocketSOAP for echoString");        CoEnvelope soap=new CoEnvelope();        HTTPTransport h=new HTTPTransport();        soap.MethodName="echoString";        soap.URI="urn:xmethodsInterop";        soap.Parameters.Create("inputString", "Hello World", "", null, null);        h.SOAPAction = "http://soapinterop.org/" ;        h.Send ( "http://www.whitemesa.net/interop/std", soap.Serialize() );        soap.Parse(h, null);        Console.WriteLine(soap.Parameters.get_Item(0).Value);    }}
编译的时候加入PocketSOAP.dll
csc test.cs /r:pocketSOAP.dll
例子2:
using PocketSOAP;using System;public class test{    public static void Main(string[] args)    {        Console.WriteLine("Starting C# PocketSOAP for echoStringArray");        CoEnvelope soap = new CoEnvelope();        HTTPTransport h = new HTTPTransport();        soap.MethodName = "echoStringArray";        soap.URI        = "http://soapinterop.org/";                Object[] sa = new Object[2];        sa[0] = "hello";        sa[1] = "goodbye";        soap.Parameters.Create ( "inputStringArray", sa, "", null,null ) ;        Console.WriteLine("Encoding style: "+soap.EncodingStyle);        Console.WriteLine("Method Name : "+soap.MethodName);        Console.WriteLine("URI : "+soap.URI);        Console.WriteLine(soap.Serialize());        h.SOAPAction = "http://soapinterop.org/" ;        h.Send("http://www.whitemesa.net/interop/std", soap.Serialize());        soap.Parse(h, null);        object[] res = (object[])soap.Parameters.get_Item(0).Value;        Console.WriteLine(res[0]);        Console.WriteLine(res[1]);    }}例子3:
using System;using System.Collections;using PocketSOAP; public class XMListings{    public static void Main()    {        CoEnvelope soap=new CoEnvelope();        HTTPTransport h=new HTTPTransport();        h.SOAPAction="";        soap.MethodName="getAllSOAPServices";        soap.URI="urn:xmethodsServicesManager";        h.Send("http://www.xmethods.net/soap/servlet/rpcrouter", soap.Serialize());                soap.Parse(h, null);        Object[] u = (object[])soap.Parameters.get_Item(0).Value;        foreach (ISOAPNode x in u)        {            Console.WriteLine(x.Nodes.get_ItemByName("name","").Value);            Console.WriteLine(x.Nodes.get_ItemByName("owner","").Value);            Console.WriteLine(x.Nodes.get_ItemByName("serverImplementation","").Value);            Console.WriteLine("-------------------------------");        }        return;    }}
更多文章 更多内容请看.NET移动与嵌入式技术.NET开发手册专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章