日期:2012-09-14 浏览次数:20409 次
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]); &n