WCF Web服务:可见性和数据库问题 [英] WCF Web Service: Visibility and Database Problems
问题描述
对大家的问候.我真的是WCF的新手,我需要创建一个RESTFUL WebService来处理数据库请求(和数据操作).我已经在Windows 7 Home Premium上安装了Visual Studio 2010 Professional,SQL Server 2008 R2和IIS7. Web服务 我已经在.net 4.0上创建了本地主机,但是如果我尝试在IIS上运行它,则每当尝试使用具有数据库连接的服务时,我都会收到请求错误:服务器在处理以下内容时遇到错误:要求.有关更多详细信息,请参阅服务器日志. (不需要DB连接的方法可以很好地工作).此外,如果我尝试从另一台计算机(使用IP代替本地主机)访问Accede的任何服务,则会收到超时异常.
Greetings to everybody. I'm really new to WCF and I need to create a RESTFUL WebService that handles DB request (and data manipulation). I've installed Visual Studio 2010 Professional, SQL Server 2008 R2 and IIS7 on Windows 7 Home Premium. The WebService I've created on .net 4.0 works fine in localhost, but if I try to run it on IIS, whenever I try to consume a service that has a DB connection I get a Request Error : "The server encountered an error processing the request. See server logs for more details." (Methods that do not need DB connection work fine thought). Furthermore, if I try to Accede to ANY service from another computer (using IP instead of localhost), I get a timeout exception.
这是我的web.config文件:
This is my web.config file:
<?xml version ="1.0"?>
< configuration>
< connectionStrings>
< add name ="DB"; providerName ="System.Data.SqlClient"; connectionString =数据源= LEO-VAIO \ SQLEXPRESS;初始目录= earringStore; Trusted_Connection = True;"/>
</connectionStrings>
< system.web>
< compilation debug ="true"; targetFramework ="4.0" />
< httpRuntime maxRequestLength ="2147483647"; />
</system.web>
< system.serviceModel>
< bindings>
< webHttpBinding>
< binding name ="StreamedRequestWebBinding"
passupProxyOnLocal =真"
useDefaultWebProxy ='"false"
hostNameComparisonMode ="WeakWildcard"
sendTimeout ="10:15:00"
openTimeout ="10:15:00"
receiveTimeout ="10:15:00"
maxReceivedMessageSize ="2147483647"
maxBufferSize ="2147483647"
maxBufferPoolSize ="2147483647"
transferMode ="StreamedRequest">
< readerQuotas maxArrayLength =" 2147483647"
b maxStringContentLength ="2147483647"; />
</binding>
</webHttpBinding>
</bindings>
<服务>
<服务名="LeoService.Service1"; behaviorConfiguration =" ServiceBehaviour">
<端点地址="" binding ="webHttpBinding" bindingConfiguration ="StreamedRequestWebBinding"; contract ="LeoService.IService1" behaviorConfiguration ="web">
< identity>
< dns value =". />
</identity>
</endpoint>
</service>
</services>
<行为>
< serviceBehaviors>
<行为名称="ServiceBehaviour">
< serviceMetadata httpGetEnabled ="true"/>
< serviceDebug includeExceptionDetailInFaults ="false"/>
</行为>
</serviceBehaviors>
< endpointBehaviors>
<行为名称=网络">
< webHttp/>
</行为>
</endpointBehaviors>
</行为>
< serviceHostingEnvironment multipleSiteBindingsEnabled ="true"; />
</system.serviceModel>
< system.webServer>
< modules runAllManagedModulesForAllRequests ="true"/>
</system.webServer>
</configuration>
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DB" providerName="System.Data.SqlClient" connectionString="Data Source=LEO-VAIO\SQLEXPRESS;Initial Catalog=earringStore;Trusted_Connection=True;"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="StreamedRequestWebBinding"
bypassProxyOnLocal="true"
useDefaultWebProxy="false"
hostNameComparisonMode="WeakWildcard"
sendTimeout="10:15:00"
openTimeout="10:15:00"
receiveTimeout="10:15:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="StreamedRequest">
<readerQuotas maxArrayLength="2147483647"
maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LeoService.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint address ="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="LeoService.IService1" behaviorConfiguration="web">
<identity>
<dns value="" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我已经从教程中获取了它.我目前有3种方法,其中2种需要DB连接,而1种是出于测试目的,所以没有.我所有的服务都以JSON格式返回数据.
I've taken it from a tutorial. I have currently 3 methods, 2 need DB connection and 1 is for testing purpose so it doesn't. All my services return data in JSON format.
我认为这是一个配置问题,但是即使我花了很多时间阅读类似的问题,也无法解决.
I believe it's a configuration problem but, even if I spent quite a lot of time reading about similar problems, I couldn't solve it.
如果您需要任何其他信息,我会很乐意为您解答.
If you need any extra information, I'll happily answer you.
谢谢大家的帮助!
P.S.对于任何语法错误,我深表歉意,但我仍在努力学习英语;)
P.S. I apologize for any grammar mistake, I'm still working on my English ;)
推荐答案
使用分步指南检查我的文章希望这会有所帮助!
这篇关于WCF Web服务:可见性和数据库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!