{"id":2171,"date":"2022-08-30T15:22:38","date_gmt":"2022-08-30T15:22:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/04\/timeout-exception-calling-soap-api-from-within-a-rest-api-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:38","modified_gmt":"2022-08-30T15:22:38","slug":"timeout-exception-calling-soap-api-from-within-a-rest-api-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/timeout-exception-calling-soap-api-from-within-a-rest-api-collection-of-common-programming-errors\/","title":{"rendered":"Timeout Exception: Calling Soap API from Within a REST API-Collection of common programming errors"},"content":{"rendered":"<p>I have a very odd problem. I have a REST API that uses ServiceStack that does a few things like save payment data etc. From within that API I start building payment object so I can fire off a payment to a Payment Gateway. This payment gateway is a Soap API Using SoapHttpClientProtocol.<\/p>\n<p>The problem I am having is that the Soap API Times out. I have a stack trace that lead me to believe it is happening inside the framework somewhere.<\/p>\n<pre><code>System.Net.WebException: Error: ConnectFailure (Connection timed out) ---&gt; System.Net.Sockets.SocketException: Connection timed out\n  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in :0 \n  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in :0 \n  --- End of inner exception stack trace ---\n  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in :0 \n  at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in :0 \n  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00000] in :0 \n<\/code><\/pre>\n<p>Above is the exception I got so I believe it is happening inside the Invoke method. Here is the code which is in the proxy file.<\/p>\n<pre><code>[System.Web.Services.Protocols.SoapDocumentMethodAttribute(\"paymenturl\", RequestNamespace=\"gatewayurl\", ResponseNamespace=\"gatewayurl\", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)]\npublic string SubmitPayment(string trnXML) {\n    object[] results = this.Invoke(\"SubmitPayment\", new object[] {\n                    trnXML});\n    return ((string)(results[0]));\n}\n<\/code><\/pre>\n<p>Does anyone know why this would happen?<\/p>\n<p>Now the SOAP Payment API works though the UI. So if call it straight from the UI I can make a payment and get a successful response back. When I do it from the API it doesn&#8217;t work.<\/p>\n<p>Is this perhaps a Architectural problem which does not allow an API call from within another API?<\/p>\n<p>Has anyone come across anything like this before?<\/p>\n<p>Any help will appreciated.<\/p>\n<p id=\"rop\"><small>Originally posted 2014-01-04 02:50:57. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have a very odd problem. I have a REST API that uses ServiceStack that does a few things like save payment data etc. From within that API I start building payment object so I can fire off a payment to a Payment Gateway. This payment gateway is a Soap API Using SoapHttpClientProtocol. The problem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2171","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2171"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2171\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}