是的,你可以。
请确保您的XSD是从wsdl导入而不是嵌入您的wsdl。
点xjc(来自Jaxb2)在你的xsd并让它产生你的类。
现在检查你的模式。
如果您的请求和响应元件具有嵌入的复杂类型使用此:
RequestElement requestElement = new RequestElement();
ResponseElement responseElement = (ResponseElement) webServiceTemplate.marshalSendAndReceive(requestElement);
否则(参考复杂类型)使用此:
RequestType requestType = new RequestType();
JAXBElement<RequestType> request = new ObjectFactory().createRequestType(requestType);
ResponseType responseType = ((JAXBElement<ResponseType>) webServiceTemplate.marshalSendAndReceive(request)).getValue();
RequestElement,ResponseElement,的RequestType和的responseType当然只是例子。将它们替换为Xjc从您的模式生成的任何类。
这帮助我使用Spring WS和JAXB2来设置我的webservice客户端。我逐字复制了那个给我导入错误的RequestElement和ResponseElement。事实证明,这些只是我想用的真实元素的占位符:)也许你应该注意到这一点。 – chris 2010-12-03 13:41:13
好点。谢谢 !编辑我的答案。 – 2010-12-03 14:27:11