I have been using WCF for a few years now and am fairly comfortable with it, however there is one simple WCF concept that I have yet to employ and am having difficulties with it.
Following this article about WCF addressing as it specifically relates to multiple endpoints in IIS I see these two excerpts:
"Suppose you have a file named calc.svc and you place it in a virtual directory that corresponds to (http://localhost:8080/calcservice). The base address for this service will be (http://localhost:8080/calcservice/calc.svc)."
and
"Now, consider the endpoint configuration found in the virtual directory’s web.config file (in Figure 3). In this case, the address of the first endpoint becomes the same as the base address (http://localhost:8080/calcservice/calc.svc) since I left the endpoint address empty. The address of the second endpoint becomes the combination of the base address appended with "secure", like this: (http://localhost:8080/calcservice/calc.svc/secure)."
Now in my application I'm trying to create two endpoints for the same service (shown below). The service name is MainService.svc. For endpoint one I have address="" and endpoint two has address="Soap11". Bringing the site up in IIS I can successfully hit this URL: (https://localhost:444/MainService.svc). This is the base address for the service according to all the documentation I can find. According to this article and others I have seen that confirm its information I should have the second endpoint at (https://localhost:444/MainService.svc/Soap11) but if I navigate to that URL I get a .Net exception indicating the resource is not found.
Is there a tool I can use to see where my different endpoints will be available? Maybe some IIS or aspnet_isapi.dll logging I can turn on? My web.config section defining my endpoints follows.
Thanks in advance for your help
<service behaviorConfiguration="MyService.MainServiceBehavior" name="MyService.MainService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSBindingConfig" contract="MyService.IMainService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="Soap11" binding="basicHttpBinding" bindingConfiguration="BasicBindingWithCredentials"
contract="MyService.IMainService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
Looking further I see that the WSDL does reference these two endpoints and in the places I expect to find them. I am still having difficulty using them however. This is what the service has in it:
<wsdl:service name="MainService">
<wsdl:port name="WSHttpBinding_IMainService" binding="tns:WSHttpBinding_IMainService">
<soap12:address location="https://localhost/MainService.svc/Soap12" />
开发者_StackOverflow社区 <wsa10:EndpointReference>
<wsa10:Address>https://localhost/MainService.svc/Soap12</wsa10:Address>
<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<Dns>localhost</Dns>
</Identity>
</wsa10:EndpointReference>
</wsdl:port>
<wsdl:port name="BasicHttpBinding_IMainService" binding="tns:BasicHttpBinding_IMainService">
<soap:address location="https://localhost/MainService.svc/Soap11" />
</wsdl:port>
</wsdl:service>
Trying to point my client at either URL (https://localhost/MainService.svc/Soap11 or Soap12) however does not work. I get an "Internal Server Error 500" as a base exception with "The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)" as the outermost exception.
I'm not sure that I found the answer but I doubt that there will be any more activity here so there is no harm in marking this answered. Here is what I have found.
The configuration I have above is apparently correct but, although I didn't see any information online about this apparently the metadata is found at the base address no matter how many endpoints you have for your service. It appears as though you are expected to use the base address to generate the proxy for the client and then repoint your code to the /Soap11 or /Soap12 address.
I have successfully been able to send calls to Soap11 using a basicHttpBinding from the client but haven't been successful communicating with Soap12 using a wsHttpBinding although I don't think this communication issue is related to the question at hand.
The only reservation I have is it seems like there should be a way to point to a single URL to both get your WSDL and send your communication although with this solution you cannot.
精彩评论