2011-03-23 79 views
3

在我的WCF服務我有一個功能,例如:* Result和* Result在WCF服務中指定的參數?

bool ValidateLogin(string user, string password) 

後我主持它在Windows Azure中,並添加引用到我的web應用程序,該功能成爲:

bool ValidateLogin(string user, string password, out int ValidateLoginResult, out bool ValidateLoginResultSpecified) 

有誰知道這兩個參數是什麼?我怎麼能阻止它被託管後添加?

+0

是什麼讓你認爲這個問題是特定於天青? – 2011-03-23 18:50:05

+0

我認爲這是代理生成時,託管,而不是Azure :) – 2011-03-24 03:45:36

回答

4

顯然,這來自於WSDL發生器,在這種情況下所使用的「添加Web引用...」 VS 2005的選項:

http://devpinoy.org/blogs/cruizer/archive/2008/10/05/some-wcf-gotchas.aspx

在MSDN論壇上的回答也暗示了傳統支持:

http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/406a6b6b-9dab-469d-ad0f-1f8f95cf0656

所以我的答案,我會猜你的客戶端是.NET 2?

+0

我使用VS 2010。NET 4 – 2011-03-24 03:38:19

+0

但你的鏈接可以幫助我很多,我想通過我的OperationContract使用XmlSerializer,因爲代理生成了... – 2011-03-24 03:44:20

+0

如果不使用XmlSerializer,而是使用「添加服務引用「?你之前使用「添加Web引用」嗎? – 2011-03-24 03:57:29

1

你如何將WCF添加到你的客戶端應用程序?這看起來與Azure毫無關係 - 它與您如何定義[DataContract]以及如何將其導入到您的客戶端代碼中有關。

我想如果你在客戶端使用WCF,那麼你不會看到這些額外的參數。

看到一個可能的解釋(或者可能是相關的問題)在這裏 - http://blogs.msdn.com/b/eugeneos/archive/2007/02/05/solving-the-disappearing-data-issue-when-using-add-web-reference-or-wsdl-exe-with-wcf-services.aspx

+0

感謝您的回覆,upvote :) – 2011-03-24 03:44:37

0

在您的客戶端項目中,確保您選擇了「添加服務引用」而不是「添加Web引用」。 「添加服務引用」使用WCF,而「添加Web引用」不會,並通過添加「[paramName]指定的」附加參數來補償可選參數。

1

添加或更換您的IService接口上面下面的代碼:

[ServiceContract (Namespace="http://www.yoursite.com/"),XmlSerializerFormat] 

Source

6

的XmlSerializerFormat樣式設置爲RPC做的把戲我。即

[OperationContract, XmlSerializerFormat(Style = OperationFormatStyle.Rpc)] 
bool ValidateLogin(string user, string password) 

它改變生成WSDL的方式,從:

<wsdl:message name="IService_ValidateLogin_InputMessage"> 
    <wsdl:part name="parameters" element="tns:ValidateLogin" /> 
</wsdl:message> 
<wsdl:message name="IService_ValidateLogin_OutputMessage"> 
    <wsdl:part name="parameters" element="tns:ValidateLoginResponse" /> 
</wsdl:message> 

要:

<wsdl:message name="IService_ValidateLogin_InputMessage"> 
    <wsdl:part name="user" type="xsd:string" /> 
    <wsdl:part name="password" type="xsd:string" /> 
</wsdl:message> 
<wsdl:message name="IService_ValidateLogin_OutputMessage"> 
    <wsdl:part name="ValidateLoginResult" type="xsd:boolean" /> 
</wsdl:message> 

本文提出了不同的解決方案,而且還包括一些額外的解釋:http://www.codeproject.com/Articles/323097/WCF-ASMX-Interoperability-Removing-the-Annoying-xx

1

以下代碼適合我:

[ServiceContract] 
[XmlSerializerFormat] 
public interface IService1 
{ 
    // do code here 
} 
相關問題