大侠们指点下小弟啊
客户端通过
UserService us = new UserService();
IUserService is = us.getUserSoapPort();
User user = is.login("九霄", "123");
System.out.println(user.getNickname());获取不到返回值,但是服务器端能够接收到数据
但是客户端通过下面的方式获取到的soap信息很正常 ,附源码
//1、创建服务(Service)
String ns = "http://www.jiuxiao.com/user/";
URL url = new URL("http://localhost:9997/10_in_tomcat/ns?wsdl");
QName sname = new QName(ns,"userService");
Service service = Service.create(url,sname);
//2、创建Dispatch
Dispatch dispatch = service.createDispatch(new QName(ns,"userSoapPort"),SOAPMessage.class, Service.Mode.MESSAGE);
//3、创建SOAPMessage
SOAPMessage msg = MessageFactory.newInstance().createMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
SOAPBody body = envelope.getBody();
//4、创建QName来指定消息中传递数据
QName ename = new QName(ns,"login");
SOAPBodyElement ele = body.addBodyElement(ename);
ele.addChildElement("username").setValue("九霄");
ele.addChildElement("password").setValue("123");
msg.writeTo(System.out);
System.out.println("\n invoking.....");
//5、通过Dispatch传递消息,会返回响应消息
SOAPMessage response = dispatch.invoke(msg);
response.writeTo(System.out);
//将响应的消息转换为dom对象
Document doc = response.getSOAPPart().getEnvelope().getBody().extractContentAsDocument();
String str =doc.getElementsByTagName("user").item(0).getTextContent();
System.out.println(str);