You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用SoapUI调用Web Service POST请求返回400 Bad Request求助

Troubleshooting HTTP 400 Bad Request for SOAP InsertOrders Service

Let's break down the most likely causes for your 400 Bad Request error—this almost always points to a malformed SOAP request that the server can't parse correctly.

Common Causes & Fixes

1. Invalid Namespace for the kn Prefix

Looking at your SOAP envelope, the kn namespace is set to http://..//soapAction — this is clearly a placeholder from the example you used, not the actual namespace required by the service.

SOAP relies heavily on namespaces to identify the operation being called (in this case, kn:InsertOrders). If the server doesn't recognize this namespace, it won't know how to process your request, resulting in a 400 error.

Fix: Replace http://..//soapAction with the actual namespace URL provided by the Web Service documentation or WSDL.

2. Unescaped XML in the XmlOrders Parameter

Since XmlOrders expects a string value, you can't directly embed raw XML inside the SOAP envelope without escaping special characters. The inner XML tags (<EXAMPLE>, <HEADER>, etc.) will break the structure of the outer SOAP envelope, causing the server's XML parser to fail.

Fix: Escape all XML special characters in your inner XML string:

  • Replace < with &lt;
  • Replace > with &gt;
  • Remove the <?xml version="1.0" encoding="utf-8"?> declaration (this is redundant inside a SOAP envelope and can cause parsing conflicts)

Your escaped XmlOrders content should look like this:

&lt;EXAMPLE xmlns="EXAMPLE"&gt;
  &lt;HEADER&gt;
    &lt;ID&gt;G112233&lt;/ID&gt;
    &lt;TR&gt;AB123&lt;/TR&gt;
  &lt;/HEADER&gt;
  &lt;HEADER&gt;
    &lt;ID&gt;G123123&lt;/ID&gt;
    &lt;TR&gt;AB1234&lt;/TR&gt;
  &lt;/HEADER&gt;
  &lt;DETAIL&gt;
    &lt;DETAILID&gt;123123123&lt;/DETAILID&gt;
    &lt;TXT&gt;ATR_123&lt;/TXT&gt;
  &lt;/DETAIL&gt;
  &lt;DETAIL&gt;
    &lt;DETAILID&gt;123123123&lt;/DETAILID&gt;
    &lt;TXT&gt;ATR_123&lt;/TXT&gt;
  &lt;/DETAIL&gt;
&lt;/EXAMPLE&gt;

3. Missing/Invalid stringLength Parameter

The stringLength field is present in your SOAP envelope but marked with a ? — this is likely a required parameter that expects the exact length of the XmlOrders string (after escaping). If you leave it as a placeholder or provide an incorrect value, the server's validation will fail.

Fix: Calculate the length of your escaped XmlOrders string and insert that number here. For example, if the escaped string is 500 characters long, set <kn:stringLength>500</kn:stringLength>.

4. SOAP Version Mismatch

Your envelope uses the SOAP 1.2 namespace (http://www.w3.org/2003/05/soap-envelope). If the Web Service only supports SOAP 1.1, this will cause a 400 error.

Fix:

  • Check the service's WSDL or documentation to confirm the supported SOAP version.
  • If using SOAP 1.1, replace the soap namespace with http://schemas.xmlsoap.org/soap/envelope/ and set your request's Content-Type header to text/xml; charset=utf-8 (SOAP 1.2 uses application/soap+xml; charset=utf-8).

Additional Debugging Steps

  • Use SoapUI's "Raw" view to inspect the exact request being sent — this will help you spot any typos or unescaped characters that might be breaking the envelope.
  • Enable more detailed logging on the server side (if you have access) or use a tool like Fiddler to capture the full request/response and check for parsing errors.

内容的提问来源于stack exchange,提问作者Ioannis Brant-Ioannidis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:03:30