您的位置:首页 > 编程语言 > C#

axis2调用c#WebService

2014-06-12 11:32 453 查看
用到axis2与axiom的jar



示例代码:

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;

Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction(namespace + method);
options.setTo(new EndpointReference(uri));
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(namespace, "");
OMElement data = fac.createOMElement(method, omNs);
OMElement inner = fac.createOMElement("flightinfoid", omNs);
inner.setText(legId);
data.addChild(inner);

ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(data);




                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: