zoukankan      html  css  js  c++  java
  • SoapHttpClientProtocol,调用制定服务的指定方法 狼

    一、SoapHttpClientProtocol类可以直接访问指定的webService的指定方法。

    先决条件:

    1. 必须给该类的Url熟悉赋值,该Url表示服务的具体路径。
    2. 具体的类必须继承该类。
    3. 必须在继承类上添加这些特性:尤其是 WebServiceBinding(Name = "Soap", Namespace = "http://tempuri.org/")]
    4.  完整的特性有:  [GeneratedCode("System.Web.Services", "2.0.50727.3053"),
         DesignerCategory("code"), DebuggerStepThrough,
          WebServiceBinding(Name = "Soap", Namespace = "http://tempuri.org/")]
    5. 调用方式如下:

    以字符串为参数

    public string Request(string requestXML)
    {

    object[] array = base.Invoke("Request", new object[]
    {
    requestXML
    });
    return (string)array[0];
    }

    以实体传递参数

            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Request", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            public JobMsgEntity Request(Entity jme)
            {
                object[] results = this.Invoke("Request", new object[] {
                        jme});
                return ((Entity)(results[0]));
            }

    说明:

    Request:表示需要调用的方法。

    requestXML:表示传入的参数,该参数是序列化后的xml参数。

    类似如下格式:

    <?xml version="1.0"?>

    <Request>

    <Header UserID="120201" RequestType="Flight.Order.FlightMessage.SendMessage" AsyncRequest="false" Timeout="0" MessagePriority="3" />

    <SendMessageRequest>

    <OrderID>511017689</OrderID>

    <Message>通知内容</Message>

    <Type>出票</Type>

    <Priority>10</Priority>

    <Sender>System</Sender>

    <Recipients>CP</Recipients>

    <SendCode />

    </SendMessageRequest>

    </Request>

  • 相关阅读:
    基于WINCE6.0+S3C2443的camera驱动
    WINCE下基于SL031的RFID功能的实现
    WINCE6.0+S3C2443下的activesync问题
    WINCE6.0+S3C2443下WatchDog学习
    错误的抉择,痛悔
    WINCE5.0下SQL server compact版本更新
    做生意和打工的区别
    WINCE基于MC8630的3G模块的控制和加载
    Xml Tips
    VB.NET and C# Comparison
  • 原文地址:https://www.cnblogs.com/gowhy/p/2831321.html
Copyright © 2011-2022 走看看