Hi, I've imported a wsdl using wsdl2java with JAXB as databinding, the
generated Service interface is like this:
@WebService(targetNamespace = "http://www.sii.example.it/SWG1", name =
"SWG1")
@XmlSeeAlso({it.au.switchgas.swg1.messaggio.ObjectFactory.class,
it.au.switchgas.swg1.strutturegenerali.ObjectFactory.class,
it.au.switchgas.strutturegas.ObjectFactory.class,
it.au.switchgas.swg1.flussi.ObjectFactory.class})
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface SWG1 {
@WebMethod(operationName = "SWG1.0050", action = "SWG1.0050")
@WebResult(name = "MessaggioSII", targetNamespace = "
http://www.sii.example.it/SWG1", partName = "MessaggioSII")
public it.au.switchgas.swg1.messaggio.ResponseMessageType swg10050(
@WebParam(partName = "MessaggioSII", name = "MessaggioSII")
it.au.switchgas.swg1.messaggio.SWG1MessageType messaggioSII
);
}
SWG1MessageType is a subclass of MessageType and it's defined like this:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SWG1MessageType")
public class SWG1MessageType extends MessageType { }
the provider of the service is currently rejecting my messages complaining
about
the MessaggioSII missing the xsi:type definition, inspecting the request I
indeed noticed
the lack of xsi:type for the MessaggioSII element:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:SWG1.0050 xmlns:ns1="http://www.sii.example.it/SWG1">
<MessaggioSII
xmlns:ns2="
http://www.example.it/schemas/SII_AU/StruttureGenerali/v1.9"
xmlns:ns3="
http://www.example.it/schemas/SII_AU/Flussi_SWG1/v1"
xmlns:ns4="
http://www.example.it/schemas/SII_AU/StruttureGAS/v1.7"
xmlns:ns5="
http://www.example.it/schemas/2010/SII_AU/MessaggioSII">
<!-- no xsi:type here -->
<ns5:RichiestaSII
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
"
xsi:type="ns5:RichiestaSwitchingRichiestaSIIType">
<!-- omissis -->
</ns5:RichiestaSII>
<ns5:DatiSII
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
"
xsi:type="ns5:RichiestaSwitchingDatiSIIType">
<!-- omissis -->
</ns5:DatiSII>
</MessaggioSII>
</ns1:SWG1.0050>
</soap:Body>
</soap:Envelope>
Is this behaviour expected?
Is there a way to add the xsi:type to the MessaggioSII element?
The only workaround I've found so far is to add a type attribute myself but
this
is not optimal either since I have to "guess" the namespace prefix (ns6 in
the example)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SWG1MessageType")
public class SWG1MessageType extends MessageType
{
@XmlAttribute(name = "type", namespace =
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)
private String xsiType = "ns6:SWG1MessageType";
}
All this is doable with xmlbeans but I'm trying to move to JAXB.
--
Alessio Bolognino