Spring Boot

时间:2018-06-09 03:49:15

标签: java spring spring-boot soap soap-client

我在Spring Boot项目中使用SOAP Web服务。我能够点击服务器,但请求将作为空值发送到服务器。

因为我没有得到什么是错的。在向服务器发送请求之前,我可以使用记录器在控制台中打印数据。

还有可能在调用服务器之前在java中打印xml格式的请求吗?

请找到以下Stub生成的方法:

 public UserListResponse UserList(UserListRequest XMLRequest) throws java.rmi.RemoteException {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[14]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("http://...../...Services/UserList");
        //_call.setProperty(org.apache.axis.client.Call.CHARACTER_SET_ENCODING,"UTF-8"); 
        _call.setEncodingStyle(null);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("http://...../...Services", "UserList"));

        setRequestHeaders(_call);
        setAttachments(_call);

        System.out.println("1 XMLRequest :: message ID ::STUB::"+XMLRequest.getHeader().toString());


 try {        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {XMLRequest});



        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        }
        else {
            extractAttachments(_call);
            try {
                return (UserListResponse) _resp;
            } catch (java.lang.Exception _exception) {
                return (UserListResponse) org.apache.axis.utils.JavaUtils.convert(_resp, UserListResponse.class);
            }
        }
  } catch (org.apache.axis.AxisFault axisFaultException) {
  throw axisFaultException;
}
    }

SOAP UI请求如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prim="http://..../..Services">
   <soapenv:Header/>
   <soapenv:Body>
      <prim:UserList>
         <!--Optional:-->
         <prim:XMLRequest>
            <!--Optional:-->
            <prim:Header>
               <!--Optional:-->
               <prim:MessageID>1</prim:MessageID>
               <!--Optional:-->
               <prim:CorrelationID>1</prim:CorrelationID>
               <!--Optional:-->
               <prim:SystemID>1</prim:SystemID>
               <!--Optional:-->
               <prim:RequestorID>1</prim:RequestorID>
               <!--Optional:-->
               <prim:InstitutionID>2</prim:InstitutionID>
            </prim:Header>
            <prim:Reference>Card</prim:Reference>
            <!--Optional:-->
            <prim:Number>500</prim:Number>
            <!--Optional:-->
            <prim:count>800</prim:count>
         </prim:XMLRequest>
      </prim:UserList>
   </soapenv:Body>
</soapenv:Envelope>

任何人都可以帮忙解决这个问题。

1 个答案:

答案 0 :(得分:0)

在application.yml或properties文件中使用以下属性.it将打印请求XML和响应XML

log4j.logger.org.springframework.ws.client.MessageTracing.sent = TRACE log4j.logger.org.springframework.ws.client.MessageTracing.received = TRACE