我正在开发一个将数据从android手机传输到服务器的解决方案(用C#/.NET编写)。
我创建了一个WCF服务,并使用仿真器进行测试,一切都很好。然后,当我试图从移动电话(连接到家庭wifi网络)登录时,我收到了以下异常消息:
拒绝连接到org.apache.http.conn.HttpHostConnectException:的
http://192.168.1.5:8000
如果任何人能够查看配置文件和接口,并就如何启用连接提供任何建议,我将非常感激。
web.config:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="DefaultBinding"
allowCookies="true"
bypassProxyOnLocal="true" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="RESTServer.LoginService">
<endpoint address=""
behaviorConfiguration="RESTFriendly"
binding="webHttpBinding"
bindingConfiguration="DefaultBinding"
contract="RESTServer.ILoginService" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>接口:
[ServiceContract()]
public interface ILoginService
{
[WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/username={username}&password={password}")]
[OperationContract]
Message Login(string username, string password);
}服务实施情况:
public class LoginService : ILoginService
{
public Message Login(string username, string password)
{
Message message = new Message();
SQLWorks sqlWorks = new SQLWorks();
string strSession = sqlWorks.Login(username, password);
string strMessage;
message.Session = strSession;
if(strSession == "")
{
strMessage = "Login failed! Please check your username/password!";
}
else
{
strMessage = "Login Successful";
}
message.ErrorMessage = strMessage;
return message;
}
}发布于 2009-03-24 05:04:15
为了连接到您的服务,它需要托管在公共web服务器上。看起来,您使用的地址192.168.1.5:8000是一个家庭网络地址,无法从外部世界访问(电话)。
发布于 2009-03-24 05:59:11
如果使用vista OS,则必须将地址添加到防火墙中。
http添加urlacl url=http://+:8000/ user=DOMAIN\user
发布于 2011-10-09 16:11:28
使用LAN将模拟器连接到Web,用于EX:http://192.168.1.78:8080/webservice
但您的局域网连接必须启用Goto:控制面板\网络和Internet\网络连接
https://stackoverflow.com/questions/676201
复制相似问题