从嵌入式客户端连接到WCF SOAP MTOM示例的400错误请求 [英] 400 Bad Request connecting to WCF SOAP MTOM sample from embedded client
问题描述
我在这里基于CodeProject示例创建了一个简单的WCF MTOM服务:< http://www.codeproject.com/Articles/632101/Mtom-Encoding-in -WCF >
我使用Windows 10计算机上运行的IIS Express托管它.我可以使用.NET客户端连接到它,并且已经捕获了HTTP请求和响应.现在,我想使用嵌入式客户端连接到该服务.
第一步,我尝试从客户端计算机上使用telnetT
捕获的HTTP请求多段消息如下:
POST/Service1.svc HTTP/1.1 MIME版本:1.0 内容类型:多部分/相关;类型=应用程序/xop + xml";开始=< http://tempuri.org/0>";边界="uuid:34450500-f156-44c4-9029-39b25c2794d5 + id = 2" ; start-info ="application/soap + xml"; VsDebuggerCausalityData:uIDPo1KWW5y3uwVDgCIgEESskYMAAAAAMvkL + qgn/EOABoi12Ti65Uyk1HOupMNEqOqG7glAPv4ACQAA 主机:192.168.0.10:8080 内容长度:865 期望:100-继续 接受编码:gzip,放气 --uuid:34450500-f156-44c4-9029-39b25c2794d5 + id = 2 内容ID:< http://tempuri.org/0> 内容传输编码:8bit 内容类型:application/xop + xml; charset = utf-8; type ="application/soap + xml"; < s:信封xmlns:s =" http://www.w3.org/2003/05/soap-envelope" xmlns:a ="http://www.w3.org/2005/08/addressing"< s:Header> a:Action s:mustUnderstand ="1"> http://tempuri .org/IService1/StoreData</a:Action>< a:MessageID> urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID>< a:ReplyTo< a:地址> http ://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>< a:To s:mustUnderstand ="1"> http://192.168. 0.10:8080/Service1.svc< a:To>/s:Header< s:Body>< StoreData xmlns =" http://tempuri.org/>< device> 22222< ;/device< time> 2016-01-10T14:34:54.2151851-06:00</time>数据AwIB</data</StoreData</s:Body>/s :信封> --uuid:34450500-f156-44c4-9029-39b25c2794d5 + id = 2--
使用Telnet发送此消息时,状态为400错误.
如果将请求简化为单个消息(不是多部分),则会得到正确的响应.简单的请求如下所示:
POST/Service1.svc HTTP/1.1 内容类型:application/soap + xml 主机:192.168.0.10:8080 内容长度:611 < s:信封xmlns:s =" http://www.w3.org/2003/05/soap-envelope" xmlns:a ="http://www.w3.org/2005/08/addressing"< s:Header> a:Action s:mustUnderstand ="1"> http://tempuri .org/IService1/StoreData</a:Action>< a:MessageID> urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID>< a:ReplyTo< a:地址> http ://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>< a:To s:mustUnderstand ="1"> http://192.168. 0.10:8080/Service1.svc< a:To>/s:Header< s:Body>< StoreData xmlns =" http://tempuri.org/>< device> 22222< ;/device< time> 2016-01-10T14:34:54.2151851-06:00</time< data> AwIB</data</StoreData</s:Body>/s :信封>
(抱歉,没有换行符.) >
我尝试最小化扩展简单案例以获取成功的多部分请求,但我继续获得状态400错误的请求.这是我最近一次尝试生成一个简单的多部分请求.我发现了很多很好的信息 此处为使用WCF的MTOM消息提供了指南,
POST/Service1.svc HTTP/1.1 MIME版本:1.0 内容类型:multipart/related; type ="application/xop + xml"; start =< http://tempuri.org/0>"; boundary ="GATES"; start-info =" ; text/xml 主机:192.168.0.10:8080 内容长度:770 -门 内容ID:< http://tempuri.org/0> 内容传输编码:8bit 内容类型:application/xop + xml; charset = utf-8; type ="text/xml"; < s:信封xmlns:s ="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a ="http://www.w3.org/2005/08/addressing"< s:Header> a:Action s:mustUnderstand ="1"> http://tempuri .org/IService1/StoreData</a:Action>< a:MessageID> urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID>< a:ReplyTo< a:地址> http ://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>< a:To s:mustUnderstand ="1"> http://192.168. 0.10:8080/Service1.svc< a:To>/s:Header< s:Body>< StoreData xmlns =" http://tempuri.org/>< device> 22222< ;/device< time> 2016-01-10T14:34:54.2151851-06:00</time< data> AwIB</data</StoreData</s:Body>/s :信封> -盖茨-
所以,有几个问题...
- 有人知道我在这里做错了吗?
- 如何从服务器端获取有关发生了什么问题(导致错误请求的原因)的更多信息.
- 有人知道我可以用来测试客户的任何公共MTOM服务吗?
谢谢!
400表示Web服务器通过400并吞下了正在抛出的真正异常.通过该程序,您将以某种方式对其进行挖掘和调试.
提琴手可能会帮助调试.
I created a simple WCF MTOM service based on the CodeProject sample here: <http://www.codeproject.com/Articles/632101/Mtom-Encoding-in-WCF>
I am hosting it with IIS Express running on a Windows 10 machine. I am able to connect to it with a .NET client, and I have captured the HTTP request and response. Now I would like to use an embedded client to connect to this service.
As a first step, I have attempted to use telnet from a client machineT
The captured HTTP request multipart message looks like this:
POST /Service1.svc HTTP/1.1 MIME-Version: 1.0 Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:34450500-f156-44c4-9029-39b25c2794d5+id=2";start-info="application/soap+xml" VsDebuggerCausalityData: uIDPo1KWW5y3uwVDgCIgEESskYMAAAAAMvkL+qgn/EOABoi12Ti65Uyk1HOupMNEqOqG7glAPv4ACQAA Host: 192.168.0.10:8080 Content-Length: 865 Expect: 100-continue Accept-Encoding: gzip, deflate --uuid:34450500-f156-44c4-9029-39b25c2794d5+id=2 Content-ID: <http://tempuri.org/0> Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml" <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IService1/StoreData</a:Action><a:MessageID>urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://192.168.0.10:8080/Service1.svc</a:To></s:Header><s:Body><StoreData xmlns="http://tempuri.org/"><device>22222</device><time>2016-01-10T14:34:54.2151851-06:00</time><data>AwIB</data></StoreData></s:Body></s:Envelope> --uuid:34450500-f156-44c4-9029-39b25c2794d5+id=2--
When I use Telnet to send this, I get a status 400 Bad request.
If I simplify the request to a single message (not multipart), I get a correct response. The simple request looks like this:
POST /Service1.svc HTTP/1.1 Content-Type: application/soap+xml Host: 192.168.0.10:8080 Content-Length: 611 <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IService1/StoreData</a:Action><a:MessageID>urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://192.168.0.10:8080/Service1.svc</a:To></s:Header><s:Body><StoreData xmlns="http://tempuri.org/"><device>22222</device><time>2016-01-10T14:34:54.2151851-06:00</time><data>AwIB</data></StoreData></s:Body></s:Envelope>
(Sorry for the lack of line breaks.)
I tried to extend the simple case minimally to get to a successful multipart request, but I continue to get status 400 Bad Request. Here is my latest attempt to generate a simple multipart request. I found a lot of good information here that gave guidelines for MTOM messages with WCF,
POST /Service1.svc HTTP/1.1 MIME-Version: 1.0 Content-Type: multipart/related;type="application/xop+xml";start="<http://tempuri.org/0>";boundary="GATES";start-info="text/xml" Host: 192.168.0.10:8080 Content-Length: 770 --GATES Content-ID: <http://tempuri.org/0> Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="text/xml" <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IService1/StoreData</a:Action><a:MessageID>urn:uuid:c6cb5104-adfd-4040-a2eb-a2cb659e8f2a</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://192.168.0.10:8080/Service1.svc</a:To></s:Header><s:Body><StoreData xmlns="http://tempuri.org/"><device>22222</device><time>2016-01-10T14:34:54.2151851-06:00</time><data>AwIB</data></StoreData></s:Body></s:Envelope> --GATES--
So, a few questions...
- Does anyone know what I am doing wrong here?
- How can I get more information from the server side about what is going wrong (what is causing the Bad Request).
- Is anyone aware of any public MTOM services that I can use to test my client?
Thanks!
The 400 means that the Web server through the 400 and swallowed the true exception that was being thrown by the program, which you'll to dig in and debug it somehow.
Fiddler may help in debugging.
这篇关于从嵌入式客户端连接到WCF SOAP MTOM示例的400错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!