*Result and *ResultSpecified parameters in WCF service?

前端 未结 6 360
[愿得一人]
[愿得一人] 2021-01-03 11:19

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

bool ValidateLogin(string user, string password)

after I hosted it in windows azure and a

相关标签:
6条回答
  • 2021-01-03 11:27

    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?

    0 讨论(0)
  • 2021-01-03 11:29

    Worked fine for me as below code:

    [ServiceContract]
    [XmlSerializerFormat]
    public interface IService1
    {
       // do code here
    }
    
    0 讨论(0)
  • 2021-01-03 11:31

    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 讨论(0)
  • 2021-01-03 11:42

    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

    0 讨论(0)
  • 2021-01-03 11:43

    Add or replace the following code above your IService Interface :

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

    Source

    0 讨论(0)
  • 2021-01-03 11:45

    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

    0 讨论(0)
提交回复
热议问题