2017-11-23 7 views
0

私のプロジェクトの1つにServiceReferenceを追加しました。このサービスが.netで作成されているかどうかは不明です。操作の1つを実行すると、この要素はヌル値でいっぱいです。私はフィドラーでチェックして、データの応答が正しく入力されています。なぜあなたはこれが起こっているのか考えていますか?自動生成されたSoapクライアントがレスポンスを解析していない

SoapResponse構造:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
     <searchOrderResponse xmlns="http://xml.comcast.com/nationalaccountsportal/services"> 
     <searchOrderReturn> 
      <ns1:searchResult xsi:type="ns1:OrderDetails" xmlns:ns1="http://xml.comcast.com/nationalaccountsportal/types"> <!-- The data --> 
      <ns2:searchResult xsi:type="ns2:OrderDetails" xmlns:ns2="http://xml.comcast.com/nationalaccountsportal/types"> 

自動生成クラス定義:WSDLで

[System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] 
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] 
    [System.ServiceModel.MessageContractAttribute(WrapperName="searchOrderResponse", WrapperNamespace="http://xml.comcast.com/nationalaccountsportal/services", IsWrapped=true)] 
    internal partial class searchOrderResponse { 

     [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/services", Order=0)] 
     [System.Xml.Serialization.XmlElementAttribute("searchOrderReturn")] 
     public OrderDetails[] searchOrderReturn; 

     public searchOrderResponse() { 
     } 

     public searchOrderResponse(OrderDetails[] searchOrderReturn) { 
      this.searchOrderReturn = searchOrderReturn; 
     } 
    } 

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1590.0")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/types")] 
    public partial class OrderDetails : object, System.ComponentModel.INotifyPropertyChanged { 

searchOrderResponse定義:

<element name="searchOrderResponse"> 
     <complexType> 
      <sequence> 
      <element maxOccurs="unbounded" name="searchOrderReturn" type="tns1:OrderDetails"/> 
      </sequence> 
     </complexType> 
     </element> 

ありがとう!

+0

が空の奇妙な実装のような音役に立てば幸い、行方不明になっただけで一つのクラスでしたリスト、つまりバグのあるサービスです。コレクション全体のNULL値が機能します。 WSDLを見ずに言うのは難しいです。 – Namphibian

+0

こんにちは@Nphphibian、私はwsdlのsearchOrderResponse定義を追加しました。他のすべての定義は、OrderDetailsの配列を直接公開するものを除き、私には標準的なものです。別の配列型応答を持たないため、このサービス内の他の操作との比較を行います –

答えて

0

WSDLが応答を間違って記述しているため、VSが間違ったコードを生成したり、タグの1つが欠落したり、VSが 'ResponseType'を生成してしまう追加:それはVSの名前にそれをしただろうかだから

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1590.0")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://xml.comcast.com/nationalaccountsportal/types")] 
public partial class SearchOrderResponseType : object, System.ComponentModel.INotifyPropertyChanged 
{ 

    private OrderDetails[] searchResultField; 

    /// <remarks/> 
    [System.Xml.Serialization.XmlElementAttribute(Order = 0)] 
    public OrderDetails[] searchResult 
    { 
     get 
     { 
      return this.searchResultField; 
     } 
     set 
     { 
      this.searchResultField = value; 
      this.RaisePropertyChanged("searchResult"); 
     } 
    } 

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 

    protected void RaisePropertyChanged(string propertyName) 
    { 
     System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; 
     if ((propertyChanged != null)) 
     { 
      propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); 
     } 
    } 
} 

お知らせプロパティは、上記応答の構造のように、クラスの名前が異なることができ、、検索結果と呼ばれるが、私はSearchOrderResponseTypeとしてそれを保たれています。この後、あなたが次のように応答クラスに戻り値の型を変更する必要があります。

[System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] 
    [System.ServiceModel.MessageContractAttribute(WrapperName="searchOrderResponse", WrapperNamespace="http://xml.comcast.com/nationalaccountsportal/services", IsWrapped=true)] 
    internal partial class searchOrderResponse { 

     [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/services", Order=0)] 
     [System.Xml.Serialization.XmlElementAttribute("searchOrderReturn")] 
     public SearchOrderResponseType searchOrderReturn; 

     public searchOrderResponse() { 
     } 

     public searchOrderResponse(SearchOrderResponseType searchOrderReturn) { 
      this.searchOrderReturn = searchOrderReturn; 
     } 
    } 

だから、基本的に、これは

関連する問題