十万火急,使用axis2,Stub调用前怎么传递soapHeader消息头参数
推荐回答
SOAPHeaderElementheader=newSOAPHeaderElement"","RequestSoapHeader";SOAPElementelement_name=header.addChildElement"name";element_name.setPrefix"";//去除前缀,如:ns1:name,取出ns1element_name.addTextNode"abc123";依次类推...最后将header加入到stub中stub.setHeaderheader;这里的stub是根据wsdl生成的。
车小霞2020-01-17 17:04:20
提示您:回答为网友贡献,仅供参考。
其他回答
-
/** * wsdl接口远程调用方法 * @param url 接口地址 * @param OperationName //需要调用的方法 * @param xml //报文 * @return 返回的报文 */public String getWSDLCallString url, String OperationName, String xml{String result = "";try {Service service = new Service;Call call = Call service.createCall;call.setTargetEndpointAddressurl;call.setOperationNameOperationName;//WSDL里面描述的接口名称call.addParameter"xml", org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN;//接口的参数call.setReturnTypeorg.apache.axis.encoding.XMLType.XSD_STRING;//设置返回类型 result = Stringcall.invokenew Object{xml};} catch Exception e {// TODO: handle exceptione.printStackTrace;}return result;。
窦运荣2020-01-17 17:00:53
-
axis2修改SOAPHeader:SendSmsServiceStub stub = new SendSmsServiceStub"http://221.236.6.218:5080/isag/North/SMS/SendSms";SendSmsServiceStub.SendSms req = new SendSmsServiceStub.SendSms;ServiceClient client = stub._getServiceClient ; Options option = client.getOptions;option.setPropertyorg.apache.axis2.transport.http.HTTPConstants.CHUNKED, false; //修改HTTP头//创建头SendSmsServiceStub.RequestSOAPHeader header = new SendSmsServiceStub.RequestSOAPHeader;SendSmsServiceStub.RequestSOAPHeaderE headerE = new SendSmsServiceStub.RequestSOAPHeaderE;headerE.setRequestSOAPHeaderheader;OMFactory fac = OMAbstractFactory.getOMFactory;client.addHeaderheaderE.getOMElementnew QName"RequestSOAPHeader","http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1", fac; //将头添加给SOAP。
齐敬甲2020-01-17 16:01:17