CXF 做webservice服务端返回的SOAP消息 为何不带<?xml version="1.0" encoding="UTF-8"?>?

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:jaxrs="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<!-- 配置方式1 注意:serviceClass为接口类并非实现类 -->
<!-- http://localhost:8090/hyteraWS/services/autheCentral?wsdl -->
<jaxws:server id="doCheckService" serviceClass="com.rx.webservice.DoCheckService"
              address="/doCheckService">
    <jaxws:serviceBean>
        <bean class="com.rx.webservice.DoCheckServiceImpl" />
    </jaxws:serviceBean>
</jaxws:server>


以上是cxf-servlet.xml配置文件

public String doCheck(String inxmlstr) {
logger.info("接收房管局监管账户验证报文:{}", inxmlstr);
XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat().setEncoding("UTF-8"));
Document reqDocument;
Element response;
try {
SAXBuilder saxBuilder = new SAXBuilder();
reqDocument = saxBuilder.build(new StringReader(new String(inxmlstr.getBytes())));
//地区码
String entno = MyJdomXml.getElement(reqDocument, "/Request/entno").trim();
//监管账户 必传
String jgzh = MyJdomXml.getElement(reqDocument, "/Request/jgzh").trim();
//监管账户户名 必传
String jgzhhm = MyJdomXml.getElement(reqDocument, "/Request/jgzhhm").trim();
if (StringUtils.isBlank(jgzh)) {
response = new Element("Response");
response.setAttribute("success", "false");
response.setAttribute("msg", "监管账户不可为空");
return xmlOutputter.outputString(new Document(response));
}
if (StringUtils.isBlank(jgzhhm)) {
response = new Element("Response");
response.setAttribute("success", "false");
response.setAttribute("msg", "监管账户户名不可为空");
return xmlOutputter.outputString(new Document(response));
}
AccInfo accInfo = new AccInfo();
accInfo.setAccNo(jgzh);
accInfo.setAccName(jgzhhm);
ResultBean resultBean = this.accInfoService.doCheck(accInfo);
response = new Element("Response");
if (!resultBean.isSuccess()) {
response.setAttribute("success", "false");
} else {
response.setAttribute("success", "true");
}
response.setAttribute("msg", resultBean.getErrMsg());
return xmlOutputter.outputString(new Document(response));
} catch (Exception e) {
response = new Element("Response");
response.setAttribute("success", "false");
response.setAttribute("msg", "解析请求报文失败");
}
return xmlOutputter.outputString(new Document(response));
}
以上是返回代码

图片说明
以上是返回内容

<?xml version='1.0' encoding='UTF-8'?>没做任何处理就没了
求解!!!!!!!

因为你看到的是body
body不是完整的xml,而是xml中的主体部分。

1.切换到Raw面板看一下 有没有 ,没有的话 请接着往下看。

2.抓包看一下 或者看POSTman的network。
如果是本身就没有这个头部呢,那就是属于 服务器的代码不规范了。
要确定是本来就没有还是postman处理之后的没有。