*Result and *ResultSpecified parameters in WCF ser

2020-02-29 10:36发布

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?

标签: wcf
6条回答
老娘就宠你
2楼-- · 2020-02-29 11:05

Add or replace the following code above your IService Interface :

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

Source

查看更多
▲ chillily
3楼-- · 2020-02-29 11:11

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.

查看更多
我只想做你的唯一
4楼-- · 2020-02-29 11:16

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

查看更多
戒情不戒烟
5楼-- · 2020-02-29 11:17

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

查看更多
做个烂人
6楼-- · 2020-02-29 11:21

Worked fine for me as below code:

[ServiceContract]
[XmlSerializerFormat]
public interface IService1
{
   // do code here
}
查看更多
7楼-- · 2020-02-29 11:25

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?

查看更多
登录 后发表回答