Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

c# - Multiple endpoints under IIS

I have been trying to add a new endpoint in a service hosted under IIS but haven't been able to figure it out for the past day or so.

This is my understanding:

  • you can have multiple endpoints under IIS as long as they have unique addresses.
  • you could assign a base address but it will be overridden by the virtual directory setup in IIS.

My virtual directory is http://localhost/WcfCert/

<services>
  <service name="WcfCertServer.Service1" behaviorConfiguration="WcfCertServer.Service1Behavior">
    <endpoint address="" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
    <endpoint address="test" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

I can bring up the service using http://localhost/wcfcert/service1.svc

but http://localhost/wcfcert/test/service1.svc/test doesn't return anything in IE or the client app

what am I missing here?

Edit:

So i did further testing, and here is what i discovered.

if i start WcfTestClient.exe and add either http://localhost:1523/Service1.svc or http://localhost:1523/Service1.svc/mex it will add both the endpoint under that address. so here is my question shouldn't http://localhost:1523/Service1.svc only represent the first endpoint? why adding that address bring up both endpoints?

but if I try to add http://localhost:1523/Service1.svc/test I get

Error: Cannot obtain Metadata from http://localhost:1523/Service1.svc/test If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:1523/Service1.svc/test Metadata contains a reference that cannot be resolved: 'http://localhost:1523/Service1.svc/test'. Sendera:BadContextTokenThe message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.HTTP GET Error URI: http://localhost:1523/Service1.svc/test There was an error downloading 'http://localhost:1523/Service1.svc/test'. The request failed with HTTP status 400: Bad Request.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It would actually be:

http://localhost/wcfcert/service1.svc/test

If you want the URL to be 'http://localhost/wcfcert/test/service1.svc', then you will need to specify the full URL in the address attribute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...