locked
New in WCF RRS feed

  • Question

  • User2029284820 posted

    Getting this error at the time of compiling WCF service:

    "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata."

    The service encountered an error:

    An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://tempuri.org/:ITIN_EXT_ServiceMobile ----> ..... bla, bla....

    My service is:

    namespace MyService
    {
        using TIN.DataMobile;       

        [ServiceContract]
        public interface ITIN_EXT_ServiceMobile
        {
            [OperationContract]
            string findContact(int eid);

            [OperationContract]
            String addUser(string uID);

            [OperationContract]
            Mob_AddSessionOut Mob_AddSession(Mob_AddSessionIn pInput);
        }
    }

    The issue is in the last service because all is fine with the first two service.

    Where:

    public class Mob_AddSessionOut
        {
            public String Auth_token { get; set; }
            public Boolean Transaction_moviment { get; set; }
            public TIN.DataAccessLayer.Gen_StatusProcess StatusProcess { get; set; }    

        }

    What am I doing wrong?

    Thanks

    Thursday, July 13, 2017 6:14 PM

Answers

  • User475983607 posted

    Mob_AddSessionOut is missing Data Member and Data Contract attributes.

    https://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute(v=vs.110).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 13, 2017 7:59 PM
  • User1168443798 posted

    Hi jfb00,

    >> Getting this error at the time of compiling WCF service:

    What do you mean by this? Do you mean you get this error when Build in VS? As my experience, this error usually produced when you add service reference at client side without exposing Service metadata.

    >> The service encountered an error

    When did you get this error? Is it a runtime error when you call service from client side? Could you share us a simple demo which could reproduce your issue?

    Did you add the three OperationContract the same time or add the third later after adding service reference?

    I suggest you follow below steps.

    1. Check the suggestion from mgebhard to add DataContract and DataMember to Mob_AddSessionOut, if TIN.DataAccessLayer.Gen_StatusProcess is another class, you also need to add DataContract and DataMember

    2. Build your service, and access the wsdl address check whether you will get any error, if you get “Metadata publishing for this service is currently disabled” exception. Add mex endpoint and set httpGetEnabled as true.

     <services>
                <!-- Note: the service name must match the configuration name for the service implementation. -->
                <service name="MyNamespace.MyServiceType" behaviorConfiguration="MyServiceTypeBehaviors" >
                    <!-- Add the following endpoint.  -->
                    <!-- Note: your service must have an http base address to add this endpoint. -->
                    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
                </service>
            </services>
     
            <behaviors>
                <serviceBehaviors>
                    <behavior name="MyServiceTypeBehaviors" >
                        <!-- Add the following element to your service behavior configuration. -->
                        <serviceMetadata httpGetEnabled="true" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
    

    3. Add or Update the service reference at client side.

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 14, 2017 5:33 AM

All replies

  • User475983607 posted

    Mob_AddSessionOut is missing Data Member and Data Contract attributes.

    https://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute(v=vs.110).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 13, 2017 7:59 PM
  • User1168443798 posted

    Hi jfb00,

    >> Getting this error at the time of compiling WCF service:

    What do you mean by this? Do you mean you get this error when Build in VS? As my experience, this error usually produced when you add service reference at client side without exposing Service metadata.

    >> The service encountered an error

    When did you get this error? Is it a runtime error when you call service from client side? Could you share us a simple demo which could reproduce your issue?

    Did you add the three OperationContract the same time or add the third later after adding service reference?

    I suggest you follow below steps.

    1. Check the suggestion from mgebhard to add DataContract and DataMember to Mob_AddSessionOut, if TIN.DataAccessLayer.Gen_StatusProcess is another class, you also need to add DataContract and DataMember

    2. Build your service, and access the wsdl address check whether you will get any error, if you get “Metadata publishing for this service is currently disabled” exception. Add mex endpoint and set httpGetEnabled as true.

     <services>
                <!-- Note: the service name must match the configuration name for the service implementation. -->
                <service name="MyNamespace.MyServiceType" behaviorConfiguration="MyServiceTypeBehaviors" >
                    <!-- Add the following endpoint.  -->
                    <!-- Note: your service must have an http base address to add this endpoint. -->
                    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
                </service>
            </services>
     
            <behaviors>
                <serviceBehaviors>
                    <behavior name="MyServiceTypeBehaviors" >
                        <!-- Add the following element to your service behavior configuration. -->
                        <serviceMetadata httpGetEnabled="true" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
    

    3. Add or Update the service reference at client side.

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 14, 2017 5:33 AM
  • User2029284820 posted

    Thanks for your reply and help.

    Do you have an example somewhere?

    I tried the next code, but still getting the error:
        [DataContract()]
        public class Mob_AddSessionOut
        {
            [DataMember]
            public String Auth_token { get; set; }

            [DataMember]
            public Boolean Transaction_moviment { get; set; }

            [DataMember]
            public TIN.DataAccessLayer.Gen_StatusProcess StatusProcess { get; set; }       
        }

    Tuesday, July 18, 2017 2:53 AM
  • User2029284820 posted

    Thanks for your reply an help!

    Getting the error at the time of build.

    You can test the WCF in VS 2017, it comes a WCF Test Client window.

    1. I am not sure about this, see my reply to mgebhard. okay, let me add the dataContract/member to IN.DataAccessLayer.Gen_StatusProcess.

    Let me pass #1 and I will reply.

    Tuesday, July 18, 2017 2:58 AM
  • User2029284820 posted

    Error continue:

    Here is the code of TIN.DataAccessLayer.Gen_StatusProcess. Do you see anything wrong? Thanks!

        [DataContract()]
        public partial class Gen_StatusProcess
        {
            [DataMember]
            public int Status { get; set; } = 1;      // return 1 no errores  2. con errores

            [DataMember]
            public string DescriptionStatus { get; set; } = "";

            [DataMember]
            public List<Gen_errorList> error_list = new List<Gen_errorList>();

            public void ProcessMsgOK(string pDescStatus)
            {
                Status = 1;                     /* 1.proceso exitoso */
                DescriptionStatus = pDescStatus;
            }


            public void AddingMsgError(string pDescStatus, int pTypeLang, string pCodeError, string pDescP1, string pDescP2, string pDescP3)
            {
                this.Status = 2;                     /* 2.proceso con errores */
                this.DescriptionStatus = pDescStatus;

                string MsgErrorTemporal = "";

                /* search in memory of general parameter the message error of specific languaje */
                //---error_list[NroItem].message_error = SearchMsgError(pCodeError, pTypeLang);      

                if (pDescP1.Length > 0)
                    MsgErrorTemporal.Replace("###", pDescP1);
            
                if (pDescP2.Length > 0)
                    MsgErrorTemporal.Replace("###", pDescP2);

                if (pDescP3.Length > 0)
                    MsgErrorTemporal.Replace("###", pDescP3);

                this.error_list.Add(new Gen_errorList(pCodeError, MsgErrorTemporal));
                    
            }
        }

    Tuesday, July 18, 2017 3:06 AM
  • User1168443798 posted

    Hi jfb00,

    >>You can test the WCF in VS 2017, it comes a WCF Test Client window

    It seems to be related with your configuration.

    Could you share us your simple project through OneDrive or GitHub? Then, we could make a test with your project.

    Best Regards,

    Edward

    Tuesday, July 18, 2017 7:26 AM
  • User2029284820 posted

    Thanks for your reply and help.

    I figured the issue, it was like the first response. I was able to fix the code in the classes, now it is working.

    Best

    Tuesday, July 25, 2017 4:02 PM