开发者

*Result and *ResultSpecified parameters in WCF service?

开发者 https://www.devze.com 2023-02-19 07:34 出处:网络
In my WCF Service I have a function, for example: bool ValidateLogin(string user, string password) after I hosted开发者_运维问答 it in windows azure and add references into my web app, that functio

In my WCF Service I have a function, for example:

bool ValidateLogin(string user, string password)

after I hosted开发者_运维问答 it in windows azure and add references into my web app, that function became:

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

Does anyone know what these two parameters are? And how can I prevent it being added after hosting?


Setting the XmlSerializerFormat Style to RPC did the trick for me. I.e.

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

It changes the way the wsdl is generated, from:

<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>

To:

<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>

This article propose a different solution, but also contains some extra explanations: http://www.codeproject.com/Articles/323097/WCF-ASMX-Interoperability-Removing-the-Annoying-xx


Apparently, this comes from the WSDL generator, in this case used on the "Add Web Reference..." option of VS 2005:

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

The answer on the MSDN forums also hints at legacy support:

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

So my answer, I'm going to guess your client is .NET 2?


How are you adding the WCF to your client app? This looks like it's nothing to do with Azure - it's more to do with how you've defined your [DataContract] and how it's imported into your client code.

I think if you use WCF on the client side then you won't see these additional parameters.

See a possible explanation (or a possibly related issue) here - 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


Add or replace the following code above your IService Interface :

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

Source


Worked fine for me as below code:

[ServiceContract]
[XmlSerializerFormat]
public interface IService1
{
   // do code here
}


In your client project, ensure that you chosen 'Add Service Reference' instead of 'Add Web Reference'. 'Add Service Reference' uses WCF while 'Add Web Reference' does not and compensates for optional parameters by adding the '[paramName]Specified' additional parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号