Given this WSDL file:
<?xml version="1.0" encoding="UTF-8”?>
<wsdl: definitions targetNamespace="http://mycompany.net/request/“
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://mycompany.net/request/“
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsd="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<xsd: complexType name=“MyReq”>
<xsd: complexContent>
<xsd: extension base="jisi: ServiceRequest">
<xsd: sequence>
<xsd: element name=“…” type="tns: …” minOccurs="O" nillable="true" />
// more elements defined
</xsd: sequence>
</xsd: extension>
</xsd: complexContent>
</xsd: complexType>
<xsd: element name=“MyRq" type="tns: MyReg" />
The following class is generated:
@XmLAccessorType (XmLAccessType.FIELD)
@XmLType (name= “MyReq”, namespace=“"http://mycompany.net/request/“ propOrder={
…
})
public class MyReq extends ServiceRequest {
…
}
An ObjectFactory
class is also generated which contains a method createMyRq
.
This returns an instance of the MyReq
class wrapped in a JAXBElement
.
Our existing application passes the JAXBElement
wrapper to a WebServiceTemplate
.
I am trying to migrate to WebFlux, and replace WebServiceTemplate
with the reactive WebClient
.
I have not got this to work using JAXBElement
, and indeed the examples I have seen which use SOAP with WebClient
wrap the request object in a Soap Envelope
, not a JAXBElement
.
When I wrap the generated MyReq
object in a SOAP envelope
, an error is returned that the request class is not annotated with @XmlRootElement
.
I tried to fix this by editing the WSDL and wrapping the complexType
in an element
, as follows:
<xsd: element name=“MyReq”>
<xsd: complexType>
<xsd: complexContent>
<xsd: extension base="jisi: ServiceRequest">
<xsd: sequence>
...
<xsd: sequence>
</xsd: extension>
<xsd: complexContent>
<xsd: complexType>
</xsd: element>
but the complier complains on this line
<xsd: element name=“MyRq" type="tns:MyReg" />
that it cannot resolve tns:MyReg
I cannot just delete that line, because MyRg
is used in other parts of the WSDL, as follows:
<wsdl: message name=“myReq”>
<wsdl: part name="request" element="tns:MyRg" />
</wsdl:messages
Is there a way to change the WSDL so that the generated MyReq
class is annotated with @XmlRootElement
?
Thanks