在mule 3.6中,HTTP post请求通过C#client进行间歇性调用

在mule 3.6中,HTTP post请求通过C#client进行间歇性调用,mule,Mule,我正在使用mule 3.6托管Web服务。 我观察到POST HTTP请求在java客户机上运行良好。但是C#客户端这个Web服务被间歇性地调用,即第一次调用正常,第二次超时,第三次调用正常,第四次超时等等。 GET HTTP请求与C#客户端配合良好 下面是mule-flow.xml的示例 C#客户机示例代码 poststring值类似于param=[{'empId':'123','empName':'xyz'}] WebRequest webRequest = (HttpWebReques

我正在使用mule 3.6托管Web服务。 我观察到POST HTTP请求在java客户机上运行良好。但是C#客户端这个Web服务被间歇性地调用,即第一次调用正常,第二次超时,第三次调用正常,第四次超时等等。 GET HTTP请求与C#客户端配合良好

下面是mule-flow.xml的示例


C#客户机示例代码 poststring值类似于param=[{'empId':'123','empName':'xyz'}]

WebRequest webRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
webRequest.Method = "POST";                
webRequest.Timeout = Timeout;
byte[] postBytes = Encoding.UTF8.GetBytes(postString);                
webRequest.ContentType = "application/x-www-form-urlencoded"; 

 StreamWriter writer = new StreamWriter(webRequest.GetRequestStream());
writer.WriteLine(postString);
writer.Close();                

WebResponse wsResponse = webRequest.GetResponse();
Console.WriteLine("Response Successful");
Stream dataStream = wsResponse.GetResponseStream();

StreamReader reader = new StreamReader(dataStream);
string response = reader.ReadToEnd();
dataStream.Close();
Console.WriteLine("Response Closed");
旋度输出

注:下入下出参数值已替换为虚拟参数,因此内容长度值可能不同

About to connect() to localhost port 7002
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 7002
> POST /getAttributes2 HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8
> Host: localhost:7002
> Accept: */*
> Content-Length: 417
> Content-Type: application/x-www-form-urlencoded
>
> param=[{'empId':'123', 'empName':'xyz'}]HTTP/1.1 200
< MULE_ENCODING: US-ASCII
< Content-Length: 719
< Date: Fri, 31 Jul 2015 09:19:20 GMT
Connection #0 to host localhost left intact
* Closing connection #0
[{"company":"xyz","department":"xyz"}]
即将连接()到本地主机端口7002
*正在尝试127.0.0.1。。。有联系的
*已连接到本地主机(127.0.0.1)端口7002
>POST/getAttributes2 HTTP/1.1
>用户代理:curl/7.15.5(x86_64-redhat-linux-gnu)libcurl/7.15.5 OpenSSL/0.9.8
>主机:localhost:7002
>接受:*/*
>内容长度:417
>内容类型:application/x-www-form-urlencoded
>
>param=[{'empId':'123','empName':'xyz'}]HTTP/1.1200
我已经找到了解决方案,似乎我们需要使用http代理,如下所示


我也遇到过同样的问题,C#HTTP POST请求通过APIKit快速地向新的HTTP侦听器发送到相同的流。我通过切换回不推荐使用的HTTP入站端点解决了这个问题,在那里这不是一个问题

<http:inbound-endpoint doc:name="HTTP" exchange-pattern="request-response"    path="api/v1/" host="${http.cs-testing-tools.host}" port="${http.cs-testing-tools.port}" />

您可以将设置添加到C#项目中的
app.config
web.config



如果希望我们帮助您调试应用程序,您需要提供更多信息。你能提供C#客户端代码吗?您还可以使用
curl
重现问题吗?您能否提供一个
curl-v-X POST…
交互的完整输出?WebRequest WebRequest=(HttpWebRequest)WebRequest.Create(requestUrl);webRequest.Method=“POST”;webRequest.Timeout=超时;byte[]postBytes=Encoding.UTF8.GetBytes(postString);webRequest.ContentType=“application/x-www-form-urlencoded”;StreamWriter writer=newstreamwriter(webRequest.GetRequestStream());writer.WriteLine(postString);writer.Close();请编辑您的问题以添加我问的额外内容,不要将其粘贴到评论中。无法阅读。嗨,@DavidDossot你能提供一些关于这个问题的专家指导吗?用户已根据您的建议编辑了问题。谢谢不幸的是,我看不到任何东西可以解释这种奇怪的行为:'(这只是一个评论
<http:inbound-endpoint doc:name="HTTP" exchange-pattern="request-response"    path="api/v1/" host="${http.cs-testing-tools.host}" port="${http.cs-testing-tools.port}" />
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ServicePoint.Expect100Continue = false;
<system.net>
  <settings> 
    <servicePointManager expect100Continue="false"/>  
  </settings> 
</system.net>