示例#1
0
        static void Main(string[] args)
        {
            Uri serviceUri = new Uri(@"http://localhost:20915/CalculateService.asmx");

            //RequestData requestData = new RequestData(serviceUri, "AddReturnOutResult");
            RequestData requestData = new RequestData(serviceUri, "Add");
            requestData.AddParam("num1", "11");
            requestData.AddParam("num2", "11");

            try
            {
                CallServiceInHttpPost(requestData);
                Console.WriteLine();
                Console.WriteLine("------------------------------------------------");
                CallServiceInSoap1_1(requestData);
                Console.WriteLine();
                Console.WriteLine("------------------------------------------------");
                CallServiceInSoap1_2(requestData);
                Console.WriteLine();
                Console.WriteLine("------------------------------------------------");
                CallWcfService();

            }
            catch (SocketException ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
示例#2
0
 private static void CallServiceInSoap1_2(RequestData requestData)
 {
     Soap1_2WSMessageGenerator soap1_2RequestMessage = new Soap1_2WSMessageGenerator();
     SocketProxy proxy = new SocketProxy(requestData.ServiceUri);
     string requestMessage = soap1_2RequestMessage.GenerateRequestMessage(requestData);
     Console.WriteLine("SOAP 1.2协议请求WebService服务的报文:");
     Console.WriteLine(requestMessage);
     Console.WriteLine();
     Console.WriteLine("响应报文:");
     Console.WriteLine(proxy.Send(requestMessage));
 }
示例#3
0
 private static void CallServiceInHttpPost(RequestData requestData)
 {
     HttpPostWSMessageGenerator httpPostMessageGenerator = new HttpPostWSMessageGenerator();
     SocketProxy proxy = new SocketProxy(requestData.ServiceUri);
     string requestMessage = httpPostMessageGenerator.GenerateRequestMessage(requestData);
     Console.WriteLine("HTTP POST协议请求WebService服务的报文:");
     Console.WriteLine(requestMessage);
     Console.WriteLine();
     Console.WriteLine("响应报文:");
     Console.WriteLine(proxy.Send(requestMessage));
 }