http://192.168.16.131/wtopprd/ws/r/awsp900?wsdl
这个wsdl 用http client 调用的话报了415 不知道请求报文应该怎么写
这块是我的soapUI请求报文 ,测试这个接口也报了500
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tip="http://www.digiwin.com.cn/tiptop/TIPTOPServiceGateWay">
<soapenv:Header/>
<soapenv:Body>
<tip:invokeSrv>
<request type="sync" key="">
<host prod="OA" ver="2.5" ip="192.168.16.131" id="" lang="zh_CN" timezone="+8" timestamp="20101025155232023" acct="ht0962" />
<service prod="T100" name="ShengchanBaogong" srvver="1.0" ip="192.168.16.131" id="topprd" />
<datakey type="FOM">
<key name="CompanyId">HT0</key>
<key name="EntId">88</key>
</datakey>
<payload>
<param key="data" type="XML" >
<![CDATA[
<Request>
<RequestContent>
<Document>
<RecordSet id="1">
<Master name="ZB_F" node_id="1">
<Record>
<Field name="enterprise" value="88"/>
<Field name="site" value="HT0"/>
<Fieldname="processnum"value="123456789"/>
<Field name="sqry" value="HT0962"/>
<Field name="sqrq" value="2020/04/23"/>
<Field name="bz" value="备注呀"/>
<Detail name="MXB_F" node_id="1_1">
<Record>
<Field name="sclh" value="B010000001"/>
<Field name="dw" value="PCS"/>
<Field name="sl" value="2000"/>
</Record>
<Record>
<Field name="sclh" value="B010000002"/>
<Field name="dw" value="PCS"/>
<Field name="sl" value="1000"/>
</Record>
</Detail>
</Record>
</Master>
</RecordSet>
</Document>
</RequestContent>
</Request>
]]>
</param>
</payload>
</request>
</tip:invokeSrv>
</soapenv:Body>
</soapenv:Envelope>
测试结果
HTTP/1.1 500 OK
Date: Fri, 12 Nov 2021 08:45:14 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips
X-FourJs-Server: GAS/2.50.49-153537
X-FourJs-Web-Service: GWS Server (Build 1472459202)
Connection: close
Content-Encoding: gzip
Content-Length: 232
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:wsa="http://www.w3.org/2005/08/addressing"><faultcode>SOAP-ENV:Server</faultcode><faultstring>'request': expected 'END_ELEMENT' event</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
这是测试接口问题
以下是我的代码,代码报错400
public static String httpCilentPost(String url, String content) throws IOException {
// 获得Http客户端
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
// 创建Post请求
HttpPost httpPost = new HttpPost(url);
// 将数据放入entity中
StringEntity entity = new StringEntity(content, "UTF-8");
httpPost.setEntity(entity);
// 响应模型
String result = null;
CloseableHttpResponse response = null;
try {
//设置请求头
//特别说明一下,此处为SOAP1.1协议
//如果用的是SOAP1.2协议,改为:"application/soap+xml;charset=UTF-8"
httpPost.setHeader("data", "text/xml;charset=UTF-8");
//命名空间+方法名
//如为SOAP1.2协议不需要此项
httpPost.setHeader("SOAPAction", "invokeSrv");
// 由客户端执行(发送)Post请求
response = httpClient.execute(httpPost);
// 从响应模型中获取响应实体
HttpEntity responseEntity = response.getEntity();
System.out.println("响应ContentType为:" + responseEntity.getContentType());
System.out.println("响应状态为:" + response.getStatusLine());
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity);
System.out.println("响应内容为:" + result);
}
} finally {
// 释放资源
if (httpClient != null) {
httpClient.close();
}
if (response != null) {
response.close();
}
}
return result;
}
public static void main(String[] args) throws IOException {
StringBuffer resultBuffer = new StringBuffer();
resultBuffer.append("<request type=sync key=>");
resultBuffer.append("<host prod=OA ver=2.5 ip=192.168.16.131 id= lang=zh_CN timezone=+8 timestamp=20101025155232023 acct=ht0962 />");
resultBuffer.append("<service prod=T100 name=ShengchanBaogong srvver=1.0 ip=192.168.16.131 id=topprd />");
resultBuffer.append("<datakey type=FOM>");
resultBuffer.append("<key name=CompanyId>HT0</key>");
resultBuffer.append("<key name=EntId>88</key>");
resultBuffer.append("</datakey>");
resultBuffer.append("<payload>");
resultBuffer.append("<param key=data type=XML >");
resultBuffer.append("<![CDATA[ ");
resultBuffer.append("<Request>");
resultBuffer.append("<RequestContent> ");
resultBuffer.append("<Document>");
resultBuffer.append("<RecordSet id=1>");
resultBuffer.append("<Master name=ZB_F node_id=1>");
resultBuffer.append("<Record>");
resultBuffer.append("<Field name=enterprise value=88/>");
resultBuffer.append("<Field name=site value=HT0/> ");
resultBuffer.append("<Field name=processnum value=123456789/>");
resultBuffer.append("<Field name=sqry value=HT0962/>");
resultBuffer.append("<Field name=sqrq value=2020/04/23/>");
resultBuffer.append("<Field name=bz value=备注呀/>");
resultBuffer.append("<Detail name=MXB_F node_id=1_1>");
resultBuffer.append("<Record>");
resultBuffer.append("<Field name=sclh value=B010000001/> ");
resultBuffer.append("<Field name=dw value=PCS/> ");
resultBuffer.append("<Field name=sl value=2000/> ");
resultBuffer.append("</Record>");
resultBuffer.append("<Record>");
resultBuffer.append("<Field name=sclh value=B010000002/> ");
resultBuffer.append("<Field name=dw value=PCS/> ");
resultBuffer.append("<Field name=sl value=1000/> ");
resultBuffer.append("</Record>");
resultBuffer.append("</Detail>");
resultBuffer.append("</Record>");
resultBuffer.append("</Master>");
resultBuffer.append("</RecordSet>");
resultBuffer.append("</Document> ");
resultBuffer.append("</RequestContent>");
resultBuffer.append("</Request>");
resultBuffer.append("]]>");
resultBuffer.append("</param>");
resultBuffer.append("</payload>");
resultBuffer.append("</request>");
String xml =resultBuffer.toString();
//请求地址
String url = " http://192.168.16.131/wtopprd/ws/r/awsp900?wsdl";
/* //请求报文
String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://WebXml.com.cn/\">\n"+
"<soapenv:Header/>\n"+
"<soapenv:Body>\n"+
"<web:getChineseFonts>\n"+
"<web:byFontsLength>5</web:byFontsLength>\n"+
"</web:getChineseFonts>\n"+
"</soapenv:Body>\n"+
"</soapenv:Envelope>";*/
//调用
String result = httpCilentPost(url, xml);
}
相似问题