2015-05-07 4 views
0

У меня есть проблема здесь, что действительно раздражает ...Не удается отладить WCF службы в Visual Studio

Я создал servcice WCF с 3 простыми методами. Служба работает нормально локально, на сервере разработки и на сервере производства.

Через две недели меня попросили добавить еще несколько функций, поэтому я открыл решение и попытался построить/отладить службу ПЕРЕД ДЕЙСТВИТЕЛЬНЫМИ ИЗМЕНЕНИЯМИ, чтобы проверить ее состояние.

К сожалению, после попытки 7-8 различных решений, которые я нашел в Интернете, до сих пор не удается отладить его, и я получаю такую ​​же ошибку все время.

Error: Cannot obtain Metadata from http://localhost:50930/StService.svc 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:50930/StService.svc Metadata contains a reference that cannot be resolved: ' http://localhost:50930/StService.svc '. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:50930/StService.svc .

The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..

HTTP GET Error URI: http://localhost:50930/StService.svc There was an error downloading ' http://localhost:50930/StService.svc '. The request failed with HTTP status 400: Bad Request.

Я пытался редактировать web.config (хотя на обоих DEV & живых servsers же, за исключением соединений DB), дал разрешения на каждой Temp папку, в папке проекта, отключены и удалены любой брандмауэр или антивирус и т. д. Не может заставить его работать ...

Любые идеи?

Вот web.config согласно запросу:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <customErrors mode="Off"/> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    <caching> 
     <sqlCacheDependency enabled="true"> 
     <databases> 
      <add connectionStringName="PhotosSqlServer" name="PhotosSqlServer" pollTime="1000"/> 
     </databases> 
     </sqlCacheDependency> 
    </caching> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name ="wsMessage"> 
      <security mode ="Message"> 
      <message clientCredentialType ="Windows"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
     <netTcpBinding> 
     <binding name="NetTcpBinding_IStService" maxReceivedMessageSize="5242880" maxConnections="10"> 
      <readerQuotas maxDepth="64" maxStringContentLength="5242880" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
      <security mode="None"></security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="false"/> 
    </system.webServer> 
</configuration> 
+0

Не скомпилировано ли приложение WCF без проблем? Если это так, вы видите, как окно WCF Test Client появляется при запуске? –

+0

Да, все решение построено без ошибок. Когда я запускаю debug, появляется WCF Client Tool, и через 1-2 секунды он отвечает на ошибку. – wizard

+0

Уверены ли, что на этом сетевом адресе/порту нет службы? Просьба предоставить нам приложение App.config для приложения WCF. –

ответ

0

Внутри ваших <system.serviceModel> тегов, добавьте:

<service name="YourAppNameSpace.StService"> 
    <endpoint address="" binding="wsMessage" bindingConfiguration="NetTcpBinding_IStService" 
     contract="YourAppNameSpace.IStService" /> 
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
     contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:50930/StService" /> 
     </baseAddresses> 
    </host> 
    </service> 

Я не уверен, о параметрах. Но вы наверняка не указали service-endpoint информацию о своем App.config.

+0

Нет. такая же ошибка. Однако я должен указать, что он работал с этим web.config до 2 недель. – wizard

Смежные вопросы