Why doesn't my WCF service provide metadata locally, when I think I have set it up exactly as it is in the test environment?
Environment
My development machine has Windows Server 2003, SP2 with IIS. I have built my service locally and then set up the CSPROJ's directory as a Web site.
IIS Configuration
Web Site Description MyService IP Address (All Unassigned) TCP port 5001 Enable HTTP Keep-Alives true HomeDirectory Directory located on this computer Local Path Project directory with .svc and Web.config A开发者_如何学Gopplication Name Default Application Execute Permissions Scripts and Executables Application Pool Default ASP.NET Version 2.0.50727 Virtual Path MyService File location Path of Web.config
I modeled my IIS settings on a UAT instance that I can get proxy information from. However when I try to get proxy information on my instance with
C:\Program Files\Microsoft Visual Studio 10.0\VC>svcutil http://localhost:5001/P
mdgService.svc
I get the following error messages.
Error: Cannot obtain Metadata from http://localhost:5001/MyService.svc ...
Metadata contains a reference that cannot be resolved: 'http://localhost:5001/MyService.svc'.
There was no endpoint listening at http://localhost:5001/MyService.svc ... The remote server returned an error: (404) Not Found. ...
I cannot browse to the URL.
I have tried suggestions
- Verified that metadata behavior is used. (It's identical to working instances.)
- Allowing full control access to C:\Windows\temp to IWAM_, IUSER_, ASPNET (suggested here: WCF Metadata reference cannot be resolved) did not help.
Here is a look at my Web.config
<configuration>
<!-...-->
<system.serviceModel>
<services>
<service behaviorConfiguration="MyService.Service1Behavior" name="MyService.MyService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
contract="MyService.MyService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647"
maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I suspect that the issue is because of the missing base address. The base address should be either assigned by the iis (if not manually placed in the config), or your visual studio, if you are in the development phase, or your self host where you are expected to provide the baseaddress yourself.
Based on your host method the base address would be resolved.
If you are using a IIS to host it, the path you have hosted should give you a clue.
From your statement, I can understand you are trying to use the similar configuration as another working service. In this case your port number may not be the same (http://localhost:5000).
Try to create a .svc file and use the visual studio's option, "View in browser". This should provide you an idea of the port number being assigned.
The problem was that of permissions.
The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.
Once I granted these permissions to NETWORK SERVICE on the machine, I was able to create proxies and configure that service in my Silverlight client.
I would like to thank razlebe for pointing me in the right direction.
精彩评论