来自Azure的SOAP调用上的SocketException

时间:2019-01-30 14:55:35

标签: c# asp.net azure soap azure-web-app-service

我在连接SOAP服务时遇到问题。一切都可以在localhost上正常工作,但是在发布为azure之后(作为部署槽,但是我也尝试了具有相同效果的新WebApp),却遇到异常:

{
"Message": "An error has occurred.",
"ExceptionMessage": "There was no endpoint listening at https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.",
"ExceptionType": "System.ServiceModel.EndpointNotFoundException",
"StackTrace": "   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)\r\n   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)\r\n   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass7_0`1.<CreateGenericTask>b__0(IAsyncResult asyncResult)\r\n   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at GusConnectorSimpleTest.Controllers.TryController.<Try>d__2.MoveNext() in C:\\Users\\lkischler.INSERT-AD\\Source\\Repos\\GusConnectorSimpleTest\\GusConnectorSimpleTest\\Controllers\\TryController.cs:line 19\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
"InnerException": {
    "Message": "An error has occurred.",
    "ExceptionMessage": "Unable to connect to the remote server",
    "ExceptionType": "System.Net.WebException",
    "StackTrace": "   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)\r\n   at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.CompleteGetRequestStream(IAsyncResult result)",
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "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 194.165.48.123:443",
        "ExceptionType": "System.Net.Sockets.SocketException",
        "StackTrace": "   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)\r\n   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)\r\n   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)"
    }
}

}

它是4.7.2上的新解决方案,已更新为最新的nuget软件包。在项目中,只有向导通过wsdl地址和简单的控制器添加了ServiceReference:

public class TryController : ApiController
{
    private readonly REGON.UslugaBIRzewnPublClient _client;

    public TryController()
    {
        _client = new REGON.UslugaBIRzewnPublClient();
    }

    [HttpGet]
    public async Task<IHttpActionResult> Try()
    {
        string key = await _client.ZalogujAsync("abcde12345abcde12345"); 
        return Ok(key);
    }
}

Web.config由ServiceReference向导修改。我只添加了SOAP API文档中描述的绑定。 ServiceModel部分:

<system.serviceModel>
<bindings>
    <wsHttpBinding>
      <binding name="e3" messageEncoding="Mtom">
        <security mode="Transport">
          <transport clientCredentialType="None" />
        </security>
      </binding>
    </wsHttpBinding>
</bindings>
<client>
  <endpoint address="https://Wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc" binding="wsHttpBinding" bindingConfiguration="e3" contract="REGON.IUslugaBIRzewnPubl" name="e3" />
</client>

在本地主机上一切正常,邮递员返回200并包含一些数据。问题是在天蓝色发布后: enter image description here

我不知道出什么问题了,为什么不起作用。如有任何建议,我将不胜感激。

0 个答案:

没有答案