使用由wsdl file
生成的旧AXIS
使其与spring ws一起使用。经过全部调整之后,我可以使用旧的wsdl生成Java源代码。
现在我正在尝试从soap UI
发出请求,但是请求值在endpoint
method
中显示为null。请求正确传入backend
,但不是values
。
WSDL文件
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
<soapenv:Header/>
<soapenv:Body>
<onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="onl:SummaryObject">
<docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
<amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
<duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
<reference xsi:type="xsd:long">?</reference>
<sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
<startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
</in0>
</onl:getSummary>
</soapenv:Body>
</soapenv:Envelope>
肥皂请求:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:onl="http://online.mysite.com">
<soapenv:Header/>
<soapenv:Body>
<onl:getSummary soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="onl:SummaryObject">
<docid xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">doc123</docid>
<amount xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</amount>
<duenew xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</duenew>
<reference xsi:type="xsd:long">121212121</reference>
<sortBy xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</sortBy>
<startDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</startDate>
<visibility xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</visibility>
</in0>
</onl:getSummary>
</soapenv:Body>
</soapenv:Envelope>
端点方法:
@PayloadRoot(namespace = NAMESPACE_URI, localPart ="getSummary")
@ResponsePayload
public JAXBElement<EObjects> getSummary(@RequestPayload SummaryObject summaryObject) {
System.out.println("Am done with this"+summaryObject.getDocId());
ObjectFactory factory = new ObjectFactory();
EObjects objects = factory.createEObjects();
QName qname = new QName("http://online.mysite.com", "eobjects");
return new JAXBElement(qname, EObjects.class, objects);
}
答案 0 :(得分:0)
axis 1
不支持在spring ws or CXF
中生成的WSDL。因此,从WSDL生成的Java类将不会包含unmarshelling
中JAXB
发出的spring
的请求所需的信息。因此request
对象将以null
的形式出现。
我已经完成了一项工作,其中有两件事要做
@XmlRootElement(name =“ getSomething”,namespace = “ http://yoursite.com”)
代码
SoapMessage message = (SoapMessage) messageContext.getRequest();
ByteArrayOutputStream out = new ByteArrayOutputStream();
message.writeTo(out);
String strMsg = new String(out.toByteArray()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.parse(new InputSource(new StringReader(strMsg)));
Node getrequestObject = d.getElementsByTagName("yourtag").item(0);
JAXBContext jc = JAXBContext.newInstance(MyRequestObject.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<SummaryObject> je = unmarshaller.unmarshal(new
DOMSource(getrequestObject), MyRequestObject.class);