+ -
当前位置:首页 → 问答吧 → 使用Axis向服务器端发送SOAP消息,服务器接收不到客户端发送的参数

使用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();  
  }  
   
}

作者: thaulyshine123   发布时间: 2011-08-04

如果你传入的某个字段为null 或者 枚举类型用了 不存在的枚举值 
是无法通过soap解析的

作者: jianuMan   发布时间: 2011-10-01

热门下载

更多