我有一个托管在 IIS 上的 HTTP wcf。我使用android模拟器检查了本地机器上的服务。本地机器上的模拟器和 wcf 工作正常。
在 webbrowser 中,我可以使用以下 URL 访问服务:
http://localhost:4806/Service1.svc
在android模拟器中,我http://10.0.2.2:4806/Service1.svc
用来成功地将android与wcf连接起来。
现在我想使用 android 设备访问 PC 上的 wcf。我怎样才能做到这一点?我需要对 web.config 文件进行任何更改吗?它是 web.config 文件代码
<service name="JSONService.Service1" behaviorConfiguration="JSONService.Service1Behavior">
<!-- Service Endpoints -->
<!--Change the binding to webHttpBinding and set behaviour configuratiion to web-->
<endpoint address="" binding="webHttpBinding" contract="JSONService.IService1" behaviorConfiguration="web" >
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="JSONService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="false"/>
</behavior>
</serviceBehaviors>
<!--Newly added configuration-->
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<!--End of newly added Configuration-->
</behaviors>
感谢帮助。
编辑:
我尝试像这样使用PC的IP,http://192.168.1.67:4806/Service1.svc
并在windowsfirewall 4806中打开一个端口。我想从android设备登录并从PC上运行的wcf获得身份验证。现在,当我按下登录按钮时,应用程序会停止并给出错误取消赎回权。任何帮助在这方面都会很棒。谢谢