我正在使用第三方网络服务,我可以通过浏览器查看并运行它没有任何问题
我已将服务引用添加到visual studio并指定了namespage:
因为它是一个网络应用程序所以我已经将相关位从app.config复制到web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MembersSoap">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
<binding name="BookingsSoap">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://server/directory/Members.asmx" binding="basicHttpBinding" bindingConfiguration="MembersSoap" contract="MWSMembers.MembersSoap" name="MembersSoap" />
<endpoint address="https://server/directory/Bookings.asmx" binding="basicHttpBinding" bindingConfiguration="BookingsSoap" contract="MWSBookings.BookingsSoap" name="BookingsSoap" />
</client>
</system.serviceModel>
这是我使用MWSBookings网络服务的方法:
private string GetBookings()
{
using (MWSBookings.BookingsSoapClient client = new MWSBookings.BookingsSoapClient())
{
try
{
var bookings = client.ListBookableActivitiesClassesCourses(GetMemberAuthHeader2(), 0123456, "5", false);
return bookings.ToString();
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
}
当我构建我的解决方案并查看浏览器页面时,我收到以下错误:
https://server/directory/Bookings.asmx没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关详细信息,请参阅InnerException(如果存在)。
我搜索了Stack Overflow上的所有其他帖子,但没有一个解决方案帮助了我的情况。我已经确保安装了HTTP激活功能,我已经尝试将AppPool从appPoolIdentity运行到NetworkService并且没有帮助。还尝试在web.config中包含maxRequestLength和maxAllowedContentLength并增加限制但没有区别。
如果有人能提供任何建议,我将不胜感激。
感谢 斯科特
更新 这是完整的异常消息:
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://server/directory/Bookings.asmx
that could accept the message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
MYIP:443 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket
s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Exception& exception) --- End of inner exception
stack trace --- at
System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at
System.Net.HttpWebRequest.GetRequestStream() at
System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream(
) --- End of inner exception stack trace --- Server stack trace: at
System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream(
) at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) at
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChan
nelRequest.SendRequest(Message message, TimeSpan timeout) at
System.ServiceModel.Channels.RequestChannel.Request(Message message,
TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String
action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMes
sage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
MySolution.MWSBookings.BookingsSoap.ListBookableActivitiesClassesCourses(List
BookableActivitiesClassesCoursesRequest request) at
MySolution.MWSBookings.BookingsSoapClient.MySolution.MWSBookings.BookingsSoap
.ListBookableActivitiesClassesCourses(ListBookableActivitiesClassesCoursesReq
uest request) in D:\website\branches\csharp\Service References\MWSBookings
\Reference.cs:line 4464 at MySolution.MWSBookings.BookingsSoapClient.ListBookableActivitiesClassesCourses(AuthHeader AuthHeader, Int32 memberId, String siteId, Boolean webBookableOnly) in D:\website\branches\csharp\Service References\MWSBookings\Reference.cs:line 4473 at MySolution.ActivityFinder.GetBookings() in D:\website\branches\csharp\Service References\Classes\MyClass.cs:line 97
答案 0 :(得分:1)
问题在于代理服务器,我在调用我的webservice之前添加了以下行,并且错误消息现已消失。
var proxy = new WebProxy("myproxy:8080", true);
proxy.Credentials = new NetworkCredential("username", "password");
WebRequest.DefaultWebProxy = proxy;