2009-12-21 38 views
2

我已發送以下wsdl。我使用wsdl.exe生成了C#代理,並且還創建了我的c#網頁。使用Fiddler我已經看過SOAP響應,它包含數據。爲了讓C#程序接受SOAP響應,需要進行哪些修改的指導。請原諒wsdl的格式,我不確定使用哪種格式以獲得最佳結果。調用Java Web Service時C#響應對象包含null

WSDL

<?xml version="1.0" encoding="UTF-8" ?> 
    <wsdl:definitions xmlns:tns="https://wwf.web.spiritaero.com/tot/moves" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CreateMoveHistory" targetNamespace="https://wwf.web.spiritaero.com/tot/moves" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> 
    <wsdl:types> 
    <xsd:schema targetNamespace="https://wwf.web.spiritaero.com/tot/moves" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <xsd:element name="CreateMoveHistoryResponse" type="tns:ReturnMessage" /> 
     <xsd:element name="CreateMoveHistoryRequest" type="tns:CreateMoveHistoryContract" /> 
     <xsd:complexType name="CreateMoveHistoryContract"> 
     <xsd:sequence minOccurs="1" maxOccurs="1"> 
      <xsd:element name="FromApplication" type="xsd:string" /> 
      <xsd:element name="ActionName" type="xsd:string" /> 
      <xsd:element name="OrderNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="WorkCenter" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Zone" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Building" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Floor" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Post" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="SubCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="SubId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="ScanDate" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="AntennaId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="AntennaDescription" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="PartNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
     </xsd:sequence> 
     </xsd:complexType> 
     <xsd:complexType name="CreateMoveHistoryFacade"> 
     <xsd:sequence minOccurs="1" maxOccurs="1"> 
      <xsd:element name="FromApplication" type="xsd:string" /> 
      <xsd:element name="ActionName" type="xsd:string" /> 
      <xsd:element name="OrderNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="WorkCenter" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Zone" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Building" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Floor" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="Post" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="SubCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="SubId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="ScanDate" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="AntennaId" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="AntennaDescription" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="PartNumber" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="ReturnCode" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
      <xsd:element name="ReturnMessage" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
     </xsd:sequence> 
     </xsd:complexType> 
     <xsd:complexType name="ReturnMessage"> 
     <xsd:sequence minOccurs="1" maxOccurs="1"> 
      <xsd:element name="Message" nillable="false" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
     </xsd:sequence> 
     </xsd:complexType> 
    </xsd:schema> 
    </wsdl:types> 
    <wsdl:message name="createMoveHistoryResponse"> 
    <wsdl:part element="tns:CreateMoveHistoryResponse" name="createMoveHistoryResponse" /> 
    </wsdl:message> 
    <wsdl:message name="createMoveHistoryRequest"> 
    <wsdl:part element="tns:CreateMoveHistoryRequest" name="createMoveHistoryRequest" /> 
    </wsdl:message> 
    <wsdl:portType name="CreateMoveHistoryPort"> 
    <wsdl:operation name="createMoveHistory"> 
     <wsdl:input message="tns:createMoveHistoryRequest" /> 
     <wsdl:output message="tns:createMoveHistoryResponse" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="CreateMoveHistorySoap" type="tns:CreateMoveHistoryPort"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="createMoveHistory"> 
     <soap:operation soapAction="https://wwf.web.spiritaero.com/tot/moves/CreateMoveHistory" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="CreateMoveHistory"> 
    <wsdl:port binding="tns:CreateMoveHistorySoap" name="CreateMoveHistory"> 
     <soap:address location="http://pc790503.corp.spiritaero.com:8080/tot/moves?action=CreateMoveHistory" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

提琴手

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Header/> 
<soapenv:Body> 
    <ReturnMessage xmlns="https://wwf.web.spiritaero.com/tot/moves">   
    <Message>Successful</Message>  
    </ReturnMessage> 
</soapenv:Body> 
</soapenv:Envelope> 

C#代碼生成響應

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="https://wwf.web.spiritaero.com/tot/moves")] 
    public partial class CreateMoveHistoryResponse { 

    private string messageField; 

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

C#代碼調用Web服務

CreateMoveHistory proxy; 
     CreateMoveHistoryRequest cmhRequest; 
     CreateMoveHistoryResponse msg; 
.... 

      msg = new CreateMoveHistoryResponse(); 
      proxy = new CreateMoveHistory(); 
      cmhRequest = new CreateMoveHistoryRequest(); 
      cmhRequest.OrderNumber = "12345"; 
      cmhRequest.Zone = "2"; 
      cmhRequest.Building = "297F"; 
      cmhRequest.Floor = "1"; 
      cmhRequest.Post = "XX"; 
      msg = proxy.createMoveHistory(cmhRequest); 

問候,

D.富勒

+0

http://stackoverflow.com/questions/5460107/soap-xml-response-received-but-not-populating-response-object – capdragon 2011-04-04 17:47:03

回答

0

好吧,首先,我會監視你的網絡流量(HTTP),以確保東西被退回。如果是這樣的話,我記得在從C#到Java調用Web Service時命名空間有問題,反之亦然。其中一方擁有名稱空間聲明,另一方沒有,並且其中一方會認爲它沒有得到任何數據,因爲它正在尋找別的東西。

這是一個非常通用的解釋,但那是很久以前的事了。我記得這確實是問題的原因。您可能必須使用不同的WS客戶端來監視有效的呼叫,然後檢查從C#客戶端執行呼叫時有什麼不同。

1

如果您使用WebReferences,請檢查wsdl文件以確保targetNamespace和名稱空間相同。

希望得到這個幫助!

+0

+1:我有同樣的問題,並最終成爲一個命名空間不匹配 – capdragon 2011-04-04 12:54:41

+0

http://stackoverflow.com/questions/5460107/soap-xml-response-received-but-not-populating-response-object – capdragon 2011-04-04 17:44:33

0

我沒有在您的肥皂響應中看到CreateMoveHistoryResponse的定義...相反,我看到一個ReturnMessage ...我相信存在這個問題。

我在您的wsdl定義中看到<xsd:element name="CreateMoveHistoryResponse" type="tns:ReturnMessage" />,但我不知道wsdl.exe util爲什麼不生成正確類型的類。

希望這有助於解決這個問題...

相關問題