我有点卡住了。我有一个用于生成Java存根的WSDL(使用maven-jaxb2-plugin)。它已为Response生成了对象,但它没有为Request生成一个对象。看看WSDL我猜它是因为Request是'简单'
提取物:
<message name='getImagesRequest'>
<part name='Type' type='xsd:string'/>
<part name='Code' type='xsd:string'/>
</message>
我正在尝试:
String request = "<Type>" + inKey.getType() + "</Type>" +
"<Code>" + inKey.getCode() + "</Code>";
StreamSource requestPayload = new StreamSource(new StringReader(request));
WebServiceMessageCallback requestCallback = new WebServiceMessageCallback() {
@Override
public void doWithMessage(WebServiceMessage inMessage) throws IOException, TransformerException
{
((SoapMessage) inMessage).setSoapAction("/getImagesRequest");
}
};
SourceExtractor<SupplierList> responseExtractor = new SourceExtractor<SupplierList>() {
@Override
public SupplierList extractData(Source inSource) throws IOException, TransformerException
{
return (SupplierList) (getWebServiceTemplate().getUnmarshaller().unmarshal(inSource));
}
};
SupplierList response = (SupplierList) getWebServiceTemplate().sendSourceAndReceive(requestPayload, requestCallback, responseExtractor);
但是,所有这一切都失败了,因为“根元素之后的文档中的标记必须格式正确”才会出现相当无益的错误。
有人可以指出我正确设置有效负载的正确方向,因为我感觉我离开了标记。
谢谢!