如何从我的SOAP响应中删除额外的结果标记

How to remove extra result tag from my SOAP response(如何从我的SOAP响应中删除额外的结果标记)
本文介绍了如何从我的SOAP响应中删除额外的结果标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过这个问题,但我在任何地方都找不到我的答案。

问题是我的asmx文件中有以下代码:

namespace IrancellSmsServer
{
    [SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
    [WebService(Namespace =   "http://www.csapi.org/schema/parlayx/data/sync/v1_0/local")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class SoapServer : System.Web.Services.WebService
    {
        [WebMethod]
        public syncOrderRelationResponse syncOrderRelation(
            Sync.UserID userID,
            string spID,
            string productID,
            string serviceID,
            string serviceList,
            int updateType,
            string updateTime,
            string updateDesc,
            string effectiveTime,
            string expiryTime,
            item[] extensionInfo
            )
        {    
            syncOrderRelationResponse a = new syncOrderRelationResponse();
            a.result = 0;
            a.resultDescription = "OK";         
            return a;
        }
     }
}

结果如下:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <syncOrderRelationResponse xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">
      <syncOrderRelationResult>   //dont want this
        <result>0</result>
        <resultDescription>OK</resultDescription>
      </syncOrderRelationResult>  //dont want this
    </syncOrderRelationResponse>
  </soap:Body>
</soap:Envelope
问题是我不想要.Net自动创建的额外<syncOrderRelationResult>标记。我要把它完全移除。我已经试过[SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare)]

但不幸的是,它告诉我我应该有一个参数。我有没有办法做到这一点?

预期结果:

 <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <syncOrderRelationResponse xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">
            <result>0</result>
            <resultDescription>OK</resultDescription>
        </syncOrderRelationResponse>
      </soap:Body>
    </soap:Envelope

以下是syncOrderRelationResponse的代码:

namespace IrancellSmsServer.Sync {
    using System;
    using System.Web.Services;
    using System.Diagnostics;
    using System.Web.Services.Protocols;
    using System.Xml.Serialization;
    using System.ComponentModel;

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.6.1055.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="DataSyncBinding", Namespace="http://www.csapi.org/wsdl/parlayx/data/sync/v1_0/service")]
    public partial class DataSyncService : System.Web.Services.Protocols.SoapHttpClientProtocol {

        private bool useDefaultCredentialsSetExplicitly;

        /// <remarks/>
        public DataSyncService() {
            this.Url = global::IrancellSmsServer.Properties.Settings.Default.IrancellSmsServer_Sync_DataSyncService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }

        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }

        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }


        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
        [return: System.Xml.Serialization.XmlElementAttribute("syncOrderRelationResponse", Namespace="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local")]
        public syncOrderRelationResponse syncOrderRelation([System.Xml.Serialization.XmlElementAttribute("syncOrderRelation", Namespace="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local")] syncOrderRelation syncOrderRelation1) {
            object[] results = this.Invoke("syncOrderRelation", new object[] {
                        syncOrderRelation1});
            return ((syncOrderRelationResponse)(results[0]));
        }


        /// <remarks/>
        public void syncOrderRelationAsync(syncOrderRelation syncOrderRelation1, object userState) {
            if ((this.syncOrderRelationOperationCompleted == null)) {
                this.syncOrderRelationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsyncOrderRelationOperationCompleted);
            }
            this.InvokeAsync("syncOrderRelation", new object[] {
                        syncOrderRelation1}, this.syncOrderRelationOperationCompleted, userState);
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1055.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local")]
    public partial class syncOrderRelationResponse {

        private int resultField;

        private string resultDescriptionField;

        //private item[] extensionInfoField;

        /// <remarks/>
        public int result {
            get {
                return this.resultField;
            }
            set {
                this.resultField = value;
            }
        }

        /// <remarks/>
        public string resultDescription {
            get {
                return this.resultDescriptionField;
            }
            set {
                this.resultDescriptionField = value;
            }
        }

        /// <remarks/>
        //[System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
        //public item[] extensionInfo {
        //    get {
        //        return this.extensionInfoField;
        //    }
        //    set {
        //        this.extensionInfoField = value;
        //    }
        /
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)