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

后端 未结 16 2142
清歌不尽
清歌不尽 2020-12-04 15:42

EDIT:

After I modified the web.config and I don\'t get error that\'s good.... then I add a new page (html) and write this small code to consume the serv

相关标签:
16条回答
  • 2020-12-04 16:21

    In my case, the Webservice was generating the assembly with a different name than the project/service name. It was set like that by my predecessor developer working on the solution and I didn't know.

    It was set to -

      <serviceBehaviors>
        <behavior name="CustomServiceBehavior">
          <serviceAuthorization serviceAuthorizationManagerType="BookingService.KeyAuthorizationManager, BookingService" />
         </behavior>
     </serviceBehaviors>
    

    So, the fix was the put the right assembly name in serviceAuthorizationManagerType. The assembly name can be obtained from following path of the service project: Right click on the WCF svc project--> Select "Properties" --> From the list of tabs select "Application". Check the value against "Assembly name:" field in the list. This is the assemblyName to use for serviceAuthorizationManagerType which may not be the servicename necessarily.

      <serviceBehaviors>
        <behavior name="MyCustomServiceBehavior">
          <serviceAuthorization serviceAuthorizationManagerType="BookingService.KeyAuthorizationManager, AssemblyNameFromSvcProperties" />
         </behavior>
     </serviceBehaviors>
    

    remember to follow the instruction for serviceAuthorizationManagerType as mentioned on https://docs.microsoft.com/en-us/dotnet/framework/wcf/extending/how-to-create-a-custom-authorization-manager-for-a-service

    It says -

    Warning

    Note that when you specify the serviceAuthorizationManagerType, the string must contain the fully qualified type name. a comma, and the name of the assembly in which the type is defined. If you leave out the assembly name, WCF will attempt to load the type from System.ServiceModel.dll.

    0 讨论(0)
  • 2020-12-04 16:24

    The property IsOneWay=true may be true in the Operational contract of the interface. Remove that property to get rid of this error.

    0 讨论(0)
  • 2020-12-04 16:24

    In Visual Studio:

    1. project properties (right click on your project)
    2. Debug -> Start Options
    3. Make sure "Command line arguments" is empty
    0 讨论(0)
  • 2020-12-04 16:26

    In case you rename the svc file make sure that your markup is correct. You'll need to modify the default configuration and follow these steps: 1) Go to SVC file right click and select view markup 2) Make sure that that code behind and service pointing to correct the file and class name.

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