How can I configure JAXB settings externally in a WSDL file?

I have a WSDL file for a service implemented in .NET. I also have the same file with some โ€œsettingsโ€ made by a third party to make the file valid for wsimport , mainly from the form:

 <s:annotation> <s:appinfo> <jaxb:property name="result"/> </s:appinfo> </s:annotation> 

I would like to be able to handle the source WSDL from the provider plus these overrides, but I would like to specify them from the outside. I see that I can use the -b option for wsimport to โ€œbind filesโ€, and I tried to write an override file that currently looks like this:

 <jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jxb:bindings node="//xs:element[@name='MyElementResult']"> <jxb:property name="result"/> </jxb:bindings> </jxb:bindings> 

I checked that "MyElementName" really exists in the element found here:

 <?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="vendor-uri" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s2="http://microsoft.com/wsdl/types/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="vendor-namespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> [...] <s:element name="MyElementResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="MyElementResult" type="tns:Result" /> 

I get this warning (and therefore no changes) from wsimport :

 [ERROR] XPath evaluation of "//xs:element[@name='MyElementResult']" results in empty target node line 4 of file:/Users/..../wsdl/custom-bindings.xjb 

Am I missing something in my ads? Do I have the wrong XPath expression? If I get my XPath / overrides, are they formatted correctly to achieve the same result as if I edited the original WSDL?

Is this possible using external files, or will I have to re-modify any future versions of WSDL with the same changes?

+6
source share
1 answer

You need to specify the location of the schema in the bindings XML file.

 <jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jxb:bindings schemaLocation="PATH_TO_YOUR_WSDL#types?schema1" node="//xs:schema[@targetNamespace='SCHEMA_NAMESPACE']"> <jxb:bindings node="//xs:element[@name='MyElementResult']"> <jxb:property name="result"/> </jxb:bindings> </jxb:bindings> </jxb:bindings> 

#types?schema1 after the WSDL file name determines which scheme in WSDL you are linking, starting at 1.

0
source

Source: https://habr.com/ru/post/953784/


All Articles