新增service调用

Lhxyy
yewj 3 months ago
parent f346a6cb5e
commit f998b29d2a

@ -172,15 +172,26 @@
<artifactId>jna</artifactId>
<version>5.11.0</version>
</dependency>
<!-- Axis -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.1</version>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.8.0</version>
</dependency>
<!--okhttp-->
<!-- <dependency>-->

@ -70,6 +70,11 @@ import com.glxp.mipsdl.thirddao.ctqyy.*;
import com.glxp.mipsdl.thirddao.hlfyyy.*;
import com.glxp.mipsdl.util.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.ibatis.mapping.ParameterMode;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
@ -79,12 +84,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -2404,48 +2405,31 @@ public class HlfyyyClient extends CommonHttpClient {
}
private static final String WSDL_URL = "http://192.168.158.208:8152/ZoesoftHipService.asmx?WSDL";
private static final String NAMESPACE = "http://192.168.158.208:8152/";
private static final String SERVICE_NAME = "saveBuyApplyInfo";
public String callInterface(String msgHeader, String msgBody) throws Exception {
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("tem", NAMESPACE);
// WebService地址
private static final String METHOD_NAME = "saveBuyApplyInfo";
SOAPBody soapBody = envelope.getBody();
SOAPElement operationElement = soapBody.addChildElement(SERVICE_NAME, "tem");
SOAPElement msgHeaderElement = operationElement.addChildElement("as_msgHeader");
msgHeaderElement.addTextNode(msgHeader);
SOAPElement msgBodyElement = operationElement.addChildElement("as_msgBody");
msgBodyElement.addTextNode(msgBody);
private static final String WSDL_URL = "http://192.168.158.208:8152/ZoesoftHipService.asmx?WSDL";
SOAPElement responseElement = operationElement.addChildElement("rs_response_xml");
public String callInterface(String msgHeader, String msgBody) throws AxisFault {
// Create RPC Service Client
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
log.error("request: {}", soapMessage.toString());
// Set the target endpoint
EndpointReference targetEPR = new EndpointReference(WSDL_URL);
options.setTo(targetEPR);
soapMessage.saveChanges();
// Prepare parameters
Object[] params = new Object[]{msgHeader, msgBody, ""};
SOAPMessage soapResponse = connection.call(soapMessage, WSDL_URL);
// Define return type
Class<?>[] returnTypes = new Class[]{String.class};
SOAPBody responseBody = soapResponse.getSOAPBody();
return responseBody.getTextContent();
// Invoke the web service
Object[] response = serviceClient.invokeBlocking(QName.valueOf(METHOD_NAME), params, returnTypes);
} finally {
connection.close();
}
// Return the response
return response[0] != null ? response[0].toString() : null;
}
}

Loading…
Cancel
Save