IntelliJ HTTP Client发送SOAP XML POST请求时Body标签失效问题
解决IntelliJ HTTP Client发送SOAP XML POST请求的解析异常问题
问题根源
你当前的请求写法存在语法错误:在IntelliJ HTTP Client中,不能用Body:关键字指定请求体,这个写法会被识别为自定义Header,导致实际请求体为空,服务器读取XML时自然会报Unexpected EOF in prolog(序言中意外遇到文件结束)的错误。
正确请求写法
移除Body:行,将SOAP XML内容直接放在所有请求Header的下方,作为单独的请求体部分。你可以将XML格式化为多行结构,既方便阅读也能避免解析问题:
### Client Init POST http://localhost:8080/application/cxf/EmbeddedWebService Accept: text/xml Authorization: Bearer {{$auth.token("bearer")}} Content-Type: text/xml <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.embedded.server.qa.company.com/"> <soapenv:Header/> <soapenv:Body> <web:init> <!--Optional:--> <web:WebserviceSessionId> <id>234567</id> </web:WebserviceSessionId> <!--Optional:--> <web:WebserviceTaskId> <id>34567z</id> </web:WebserviceTaskId> <!--Optional:--> <web:InitContext> <quoteId>1234567</quoteId> <locale>de</locale> <userId>2134567</userId> <offline>false</offline> <activated>false</activated> <customData></customData> <readOnly>false</readOnly> </web:InitContext> </web:init> </soapenv:Body> </soapenv:Envelope>
验证要点
- 确保Header和请求体之间有空行分隔,这是IntelliJ HTTP Client识别请求体的关键。
- XML本身格式需正确:所有标签闭合、命名空间引用无误(你的XML结构本身无问题,问题出在请求体的传递方式)。
内容的提问来源于stack exchange,提问作者Klatuu
相关产品推荐
相关产品推荐

