Mobile调用WCF报错。没有终结点对可能接受消息的xxx进行监听。这通常是因地址或 SOAP 操作不正确所致
请大家帮忙解答一下问题,详细信息在下面。谢谢啦。
开发工具:VS2008
开发环境:XP SP3 .NET CF 3.5
部署环境:XP SP3(本机) WM5.0(模拟器)
错误详细信息:
未处理 System.ServiceModel.EndpointNotFoundException
Message="没有终结点对可能接受消息的 http://172.18.18.156:8888/LoginService 进行监听。这通常是因地址或 SOAP 操作不正确所致。有关更多详细信息,请查看 InnerException 的相关内容(如果存在)。"
StackTrace:
位于 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
位于 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
位于 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
位于 System.ServiceModel.Channels.RequestChannel.Request(Message message)
位于 Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg)
位于 Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, GetHelloRequest request)
位于 LoginServiceClient.GetHello(GetHelloRequest request)
位于 LoginServiceClient.GetHello()
位于 SmartDeviceProject2.Form1.button1_Click(Object sender, EventArgs e)
位于 System.Windows.Forms.Control.OnClick(EventArgs e)
位于 System.Windows.Forms.Button.OnClick(EventArgs e)
位于 System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
位于 System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
位于 Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
位于 System.Windows.Forms.Application.Run(Form fm)
位于 SmartDeviceProject2.Program.Main()
InnerException: System.Net.WebException
Message="未能建立与网络的连接。"
StackTrace:
位于 System.Net.HttpWebRequest.finishGetResponse()
位于 System.Net.HttpWebRequest.GetResponse()
位于 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
位于 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
位于 System.ServiceModel.Channels.RequestChannel.Request(Message message)
位于 Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg)
位于 Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, GetHelloRequest request)
位于 LoginServiceClient.GetHello(GetHelloRequest request)
位于 LoginServiceClient.GetHello()
位于 SmartDeviceProject2.Form1.button1_Click(Object sender, EventArgs e)
位于 System.Windows.Forms.Control.OnClick(EventArgs e)
位于 System.Windows.Forms.Button.OnClick(EventArgs e)
位于 System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
位于 System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
位于 Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
位于 System.Windows.Forms.Application.Run(Form fm)
位于 SmartDeviceProject2.Program.Main()
详细做法跟这个教程一样。http://www.oecp.cn/hi/csh/blog/418
服务契约:
服务契约
1.[ServiceContract]
2. public interface ILoginService
3. {
4. ///<summary>
5. /// HelloWord!
6. ///</summary>
7. ///<returns></returns>
8. [OperationContract]
9. string GetHello();
10.}
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerCall)]
public class LoginService:ILoginService
{
string ILoginService.GetHello()
{
return "Hello World! Welcome to 百洋软件研究实验室!";
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8888/LoginService" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WCFDemo.LoginService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="" binding="basicHttpBinding" contract="WCFDemo.ILoginService"/>
<!--<endpoint address="" binding="netTcpBinding" contract="WCFDemo.ILoginService"/>-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8888/LoginService" />
<!--<add baseAddress="net.tcp://localhost:9999/LoginService" />-->
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
private void button1_Click(object sender, EventArgs e)
{
SMC.Binding binding = LoginServiceClient.CreateDefaultBinding();
string remoteAddress = LoginServiceClient.EndpointAddress.Uri.ToString();
remoteAddress = remoteAddress.Replace("localhost", "172.18.18.156");
EndpointAddress endpoint = new EndpointAddress(remoteAddress);
LoginServiceClient client = new LoginServiceClient(binding, endpoint);
MessageBox.Show(client.GetHello());
}