| | |
| | | /* |
| | | package com.vci.ubcs.webservice; |
| | | |
| | | import org.apache.axiom.om.OMAbstractFactory; |
| | | import org.apache.axiom.om.OMElement; |
| | | import org.apache.axiom.om.OMFactory; |
| | | import org.apache.axiom.om.OMNamespace; |
| | | import org.apache.axiom.soap.SOAP11Constants; |
| | | import org.apache.axis2.Constants; |
| | | import org.apache.axis2.addressing.EndpointReference; |
| | | import org.apache.axis2.client.Options; |
| | | import org.apache.axis2.client.ServiceClient; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | public class WsClientUtil { |
| | | |
| | | */ |
| | | /** |
| | | * axis2调用客户端 |
| | | * |
| | | * @param url 请求服务地址 |
| | | * @param nameSpace 命名空间 |
| | | * @param soapAction soapAction |
| | | * @param method 方法名 |
| | | * @param paramName 参数名称 |
| | | * @param sendData 请求报文 |
| | | * @param timeOutInMilliSeconds 超时时间 |
| | | * @return String 类型的响应报文 |
| | | *//* |
| | | |
| | | public static String sendMsg(String url, String nameSpace,String soapAction, String method, String paramName, String sendData, long timeOutInMilliSeconds) throws Exception { |
| | | ServiceClient serviceClient = new ServiceClient(); |
| | | Options option = new Options(); |
| | | option.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); |
| | | option.setTransportInProtocol(Constants.TRANSPORT_HTTP); |
| | | |
| | | // 值为targetNamespace+methodName |
| | | if(StringUtils.isEmpty(soapAction)){ |
| | | soapAction = nameSpace+method; |
| | | } |
| | | option.setAction(soapAction); |
| | | |
| | | EndpointReference epfs = new EndpointReference(url); |
| | | option.setTo(epfs); |
| | | serviceClient.setOptions(option); |
| | | |
| | | OMFactory fac = OMAbstractFactory.getOMFactory(); |
| | | OMNamespace namespaceOM = fac.createOMNamespace(nameSpace, ""); |
| | | OMElement element = fac.createOMElement(method, namespaceOM); |
| | | OMElement theCityCode = fac.createOMElement(paramName, namespaceOM); |
| | | theCityCode.setText(sendData); |
| | | element.addChild(theCityCode); |
| | | |
| | | |
| | | OMElement resultOM = serviceClient.sendReceive(element); |
| | | |
| | | String result = resultOM.getFirstElement().getText(); |
| | | return result; |
| | | } |
| | | } |
| | | */ |