2011-12-21 223 views
0

我們希望爲客戶提供輸入Web服務的能力,我們的應用程序將檢查服務,爲他們提供輸入參數和類型,客戶將輸入參數和我們的應用程序調用該Web服務。我發現了代碼示例,它們將動態檢查和調用.asmx服務,3.5中依賴於共享接口的示例以及4.0中使用新4.0組件的示例。動態調用WCF服務

我缺少的是一種使用.NET 3.5動態檢查WCF服務而無需交換共享接口的方法。我已經能夠確定服務名稱和方法,但是WSDL上的值參數沒有通過。

這裏是我的簡單的服務:

[OperationContract] 
    string GetDataInt(int value); 

    [OperationContract] 
    string GetDataStringInt(int value, string stringValue); 

     [OperationContract] 
    string GetDataStringIntBool(int value, string stringValue, bool boolValue); 

這裏是什麼來通過作爲參數的WSDL(爲參數):

<wsdl:message name="IService1_GetDataInt_InputMessage"> 
<wsdl:part name="parameters" element="tns:GetDataInt"/> 
</wsdl:message> 
<wsdl:message name="IService1_GetDataInt_OutputMessage"> 
<wsdl:part name="parameters" element="tns:GetDataIntResponse"/> 
</wsdl:message> 
<wsdl:message name="IService1_GetDataStringInt_InputMessage"> 
<wsdl:part name="parameters" element="tns:GetDataStringInt"/> 
</wsdl:message> 
<wsdl:message name="IService1_GetDataStringInt_OutputMessage"> 
<wsdl:part name="parameters" element="tns:GetDataStringIntResponse"/> 
</wsdl:message> 

參數類型不通過就快到了wsdl。有沒有在.NET 3.5中檢查WCF服務並調用它的方法?

+1

你的意思是像[WcfTestClient](http://msdn.microsoft.com/en-us/library/bb552364.aspx)? – 2011-12-21 21:58:30

+0

就是這樣,儘管還有更多。我試圖從商業的角度來闡述我們想要做的事情,這樣人們就會明白我爲什麼要問這個問題。 – Drew 2011-12-22 19:07:16

回答

1

參數當然是來自WSDL,但WSDL並不平坦(除非您使用提供平展WSDL的WCFExtras)。您必須查找WSDL和XSD導入 - 這些導入指向包含其餘WSDL相關信息的其他文件。

+0

謝謝,我有點驚訝,開箱即用,無法使用.NET來解釋.NET WCF服務而無需第三方實用程序。 – Drew 2011-12-22 19:08:42

+0

你可以使用它。您只需加載描述該服務的所有文件。 – 2011-12-22 19:32:22