【发布时间】:2014-12-18 21:32:50
【问题描述】:
我正在桌面应用程序中使用 Soap 服务 http://example.com/soap/webservice.php。我创建了一个单独的类库包含该服务并使用这个类库在我的主应用程序中使用它,我工作正常。
这是我正在使用的代码:
MyService.PushServerWSPortTypeClient obj = new MyService.PushServerWSPortTypeClient();
string result = obj.auth(apiId, UserName, Password);
这是完美的工作。
但是当我在我的 Windows 服务中使用此服务时,我遇到了异常:
http://exmaple.com/soap/webservice.php 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。
我知道这个异常意味着它无法在我的服务中找到它的端点,但是在我的类库中,它的 app.config 中提到了端点,我还在我的Windows 服务 app.config 也是如此。
这是 app.config 中的代码:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PushServerWSBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://example.com/soap/webservice.php"
binding="basicHttpBinding" bindingConfiguration="PushServerWSBinding"
contract="MyService.PushServerWSPortType" name="PushServerWSPort" />
</client>
</system.serviceModel>
内部异常消息:
无法解析远程名称:'api.example.com'
堆栈跟踪:
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& 上下文) 在 System.Net.HttpWebRequest.GetRequestStream() 在 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
【问题讨论】:
-
你能在运行服务的机器上的浏览器中点击端点吗?从表面上看,windows 服务似乎无法解析 Web 服务端点的域名。
-
@BenRobinson 当我访问 example.com/soap/webservice.php 时,它可以在该机器上的浏览器中运行,但是当我只写这个 example.com 时,它会显示 在此服务器上找不到请求的 URL /。,这是导致问题的原因吗?
-
@BenRobinson 如果您需要,这里是确切的网址:api.clickatell.com/soap/webservice.php
标签: c# soap windows-services