Scene:
1, the WCF service successfully deploys to the IIS7, the test way:
1) The browser can open the SVC and WSDL
e.g. http://IP address : 8087/wcfservice/myservice.svc
/HTTPIP address : 8087/wcfservice/myservice.svc?wsdl
2) Manually write the client, call the relevant method is also successful
Note: the "IP address " in the above test represents the actual IP address.
2. Auto-Generate Client Agent failure using tool
1) When using the Add Service Reference tool with VS , the failure information is as follows:
The contents of the document are solved, but cannot be processed.
-The WSDL document contains links that cannot be resolved.
-An error occurred while downloading the "/ host name : 8087/wcfservice/myservice.svc?xsd=xsd0".
-Request failed due to HTTP status 400: Bad Request.
The metadata contains a reference that could not be resolved: '//IP address : 8087/wcfservice/myservice.svc?wsdl '.
There is no endpoint listening for the http:/P address that can accept the message, 8087/wcfservice/myservice.svc?wsdl. This is usually caused by an incorrect address or SOAP operation. If this condition exists, see innerexception for more information.
The remote server returned an error: (404) Not found.
If the service is already defined in the current solution, try to build the solution, and then add the service reference again.
2) When the agent is automatically generated using the SvcUtil.exe tool, the failure information is as follows:
D:\>svcutil.exe Http://IP Address/wcfservice/myservice.svc?wsdl
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (r) Communication Foundation, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
Trying to use Ws-metadata Exchange or DISCO from the "http://IP address 8087/wcfservi
ce/myservice.svc?wsdl "Download meta data.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (r) Communication Foundation, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
Error: Could not get metadata from http://IP address 8087/wcfservice/myservice.svc?wsdl
If you have access to the Windows (R) Communication Foundation Service, check whether the
Specifies the address publishing metadata. For help with enabling metadata publishing, see HTTP://GO.MICROSOFT.COM/FWL
ink/? The MSDN documentation on linkid=65455.
Ws-metadata Exchange Errors
uri:http://IP address : 8087/wcfservice/myservice.svc?wsdl
The metadata contains a reference that cannot be resolved: "//IP address : 8087/WCFSERVICE/MYSERVICE.S
VC?WSDL ".
There is no endpoint listening for the http://IP address of the message that can be accepted. 8087/wcfservice/myservi
Ce.svc?wsdl. This is usually caused by an incorrect address or SOAP operation. If this condition exists, see
See innerexception for more information.
The remote server returned an error: (404) Not found.
HTTP GET Error
uri:http://IP address : 8087/wcfservice/myservice.svc?wsdl
The contents of the document are understood, but cannot be processed.
-The WSDL document contains links that cannot be resolved.
-Download "// hostname : 8087/wcfservice/myservice.svc?xsd=xsd0" when
Wrong.
-Request failed due to HTTP status 400: Bad Request.
If you want to get more help, type "svcutil/?"
Note: the " hostname " in the above test represents the actual host name.
Analysis
1, test: Improve user rights, effect: invalid
2. Test: Add host name in IIS network binding, Effect: invalid
3, analysis reasons :
1) Error prompt:
A.vs Reference Error-An error occurred while downloading the "/ host name : 8087/wcfservice/myservice.svc?xsd=xsd0".
B.svcutil.exe Error-Error downloading '/ hostname : 8087/wcfservice/myservice.svc?xsd=xsd0 '.
Analysis: such as "host name" is "IP address".
Solve
In the IIS deployment directory, add the following items to the configuration file:
<serviceBehaviors>
<behavior name= "<name>" >
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme= "http" port= " port number "/>
<add scheme= "https" port= " port number "/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
The configuration causes WCF to generate the correct URI by using the "Host" HTTP header of the incoming metadata request. In this case, the "Host" header contains the load Balancer address instead of the internal node address.
Attention:
1) The configuration value "port number" should be the actual port number.
2) <name></name> is a placeholder that should replace the behavior name in the WCF service.
Reference:
Fix:uris in a WCF WSDL document refer to inaccessible internal instances instead of to the load balancer as expected in T He. NET Framework 3.0 in Windows Server 2003, Windows XP, Windows Vista and Windows Server 2008
Scenario 1:
The "Add Service Reference" command or the svcutil.exe command-line tool to download the metadata from the service .
In this scenarioif you try to generate a proxies from the metadata, the process fails because the metadata< /c1> contains URIs that reference internal Web site instances.
Scenario 2:
In this scenario, you notice the URIs in the WSDL document refer to inaccessible internal Web site Insta NCEs (HTTP://127.0.0.1:5001/SERVICE.SVC?WSDL).
However, expect the URIs in the WSDL document to refer to the load balancer (http://127.0.0.1:81/Service.svc? WSDL).
References:
http://support.microsoft.com/kb/971842
II7 hosted WCF service, error adding reference in VS