使用Axis向服务器端发送SOAP消息,服务器接收不到客户端发送的参数
时间:2011-08-04
来源:互联网
本程序是参照网上的一个程序改写的,服务器端是我用JAX-WS创建的一个简单web服务,但是该服务器却接收不到客户端传入的参数,接收到的参数为null。同样用这个客户端调用网上的那个天气预报的web服务,是没有问题的。请各位帮忙看一下,问题出在什么地方?
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;
public class TestSayHelloNull
{
private static EndpointReference targetEPR = new EndpointReference(
"http://localhost:8080/myFirstWS/HelloJaxwsPort?wsdl");
public void getResult() throws Exception
{
ServiceClient sender = new ServiceClient();
sender.setOptions(buildOptions());
OMElement result = sender.sendReceive(buildParam());
System.out.println(result);
}
private static OMElement buildParam()
{
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://jaxws.shaw.com/", "");
OMElement data = fac.createOMElement("sayHello", omNs);
OMElement inner = fac.createOMElement("arg0", omNs);
inner.setText("传入服务器的参数!!!!!!!!!!!!!!!!!!!!!!!!");
data.addChild(inner);
return data;
}
private static Options buildOptions()
{
Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction("http://jaxws.shaw.com/sayHello");
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return options;
}
public static void main(String[] args) throws Exception
{
TestSayHelloNull s = new TestSayHelloNull();
s.getResult();
}
}
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;
public class TestSayHelloNull
{
private static EndpointReference targetEPR = new EndpointReference(
"http://localhost:8080/myFirstWS/HelloJaxwsPort?wsdl");
public void getResult() throws Exception
{
ServiceClient sender = new ServiceClient();
sender.setOptions(buildOptions());
OMElement result = sender.sendReceive(buildParam());
System.out.println(result);
}
private static OMElement buildParam()
{
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://jaxws.shaw.com/", "");
OMElement data = fac.createOMElement("sayHello", omNs);
OMElement inner = fac.createOMElement("arg0", omNs);
inner.setText("传入服务器的参数!!!!!!!!!!!!!!!!!!!!!!!!");
data.addChild(inner);
return data;
}
private static Options buildOptions()
{
Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction("http://jaxws.shaw.com/sayHello");
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return options;
}
public static void main(String[] args) throws Exception
{
TestSayHelloNull s = new TestSayHelloNull();
s.getResult();
}
}
作者: thaulyshine123 发布时间: 2011-08-04
如果你传入的某个字段为null 或者 枚举类型用了 不存在的枚举值
是无法通过soap解析的
是无法通过soap解析的
作者: jianuMan 发布时间: 2011-10-01
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28