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

后端 未结 16 2191
清歌不尽
清歌不尽 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:19

    You need to add a metadata exchange (mex) endpoint to your service:

    
       
          
          
       
    
    

    Now, you should be able to get metadata for your service

    Update: ok, so you're just launching this from Visual Studio - in that case, it will be hosted in Cassini, the built-in web server. That beast however only supports HTTP - you're not using that protocol in your binding...

    Also, since you're hosting this in Cassini, the address of your service will be dictated by Cassini - you don't get to define anything.

    So my suggestion would be:

    • try to use http binding (just now for testing)
    • get this to work
    • once you know it works, change it to your custom binding and host it in IIS

    So I would change the config to:

    
       
          
             
          
       
    
    
       
          
              binding="basicHttpBinding" 
              contract="MyService.IMyService"/>
          
       
    
    

    Once you have that, try to do a View in Browser on your SVC file in your Visual Studio solution - if that doesn't work, you still have a major problem of some sort.

    If it works - now you can press F5 in VS and your service should come up, and using the WCF Test Client app, you should be able to get your service metadata from a) the address that Cassini started your service on, or b) the mex address (Cassini's address + /mex)

提交回复
热议问题