题
我开发transfering从机器人电话数据发送到服务器的溶液(C#编写/ .NET)。
我创建了一个WCF服务,并与仿真测试一切工作的罚款。然后,当我试图从移动电话(连接到家庭Wi-Fi网络)登录我得到了以下的异常消息:
org.apache.http.conn.HttpHostConnectException:连接到 http://192.168.1.5:8000 拒绝
我会很感激,如果anyonecould给看看配置文件和接口,并就如何启用连接的任何建议。
的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;
}
}
解决方案
为了连接到您的服务,它需要一个公共的Web服务器上托管。它看起来像你使用192.168.1.5:8000地址是家庭网络地址,这是不是从外部世界(电话)。
访问其他提示
如果您使用的是Vista操作系统,您必须将地址添加到您的防火墙
的netsh HTTP添加urlacl URL = HTTP:// +:8000 / 用户= DOMAIN \用户
使用您的局域网IP给您的仿真器的Web服务连接等,为EX: http://192.168.1.78: 8080 / web服务
但你的局域网连接,必须启用 转到:控制面板\网络和Internet \网络连接
不隶属于 StackOverflow