Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the schema inlined inside an imported WSDL

I have a.wsdl & b.wsdl where a.wsdl imports b.wsdl. Now I have to customize the schema inside b.wsdl using wsimport and JAXB. but using below customization is giving error that "XPath evaluation of "wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']" results in an empty target node

I am not able to find a way to customize the inlined schema in imported b.wsdl when generating the client code using wsimport.

    <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']"
               xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
               xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                   <jaxb:globalBindings>
                    <jaxb:javaType name="java.util.Calendar" xmlType="xsd:dateTime" 
                    parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" 
                    printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
               </jaxb:globalBindings>
   </jaxws:bindings>

A.wsdl

<definitions targetNamespace="a"
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:interface="b">
 <import location="b.wsdl" namespace="b"/>
  <service name="Service">
   <port binding="interface:Binding" name="Port">
      <soap:address location="https://localhost/sdk/vpxdService" />
   </port>
  </service>
</definitions>

B.wsdl

<definitions targetNamespace="b"
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:b="b"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <types>
   <schema
     targetNamespace="b"
     xmlns="http://www.w3.org/2001/XMLSchema"
     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:b="b"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified">
     <complexType name="XYZ">
        <sequence>
           <element name="dynamicType" type="xsd:string" minOccurs="0" />
           <element name="val" type="xsd:anyType" maxOccurs="unbounded" />
        </sequence>
     </complexType>
  </types>
 </schema>
</definitions>
like image 955
kiri Avatar asked Nov 05 '22 19:11

kiri


1 Answers

After going through given website I modified the external binding file to use wsdlLocation="b.wsdl" instead of node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']" which did the magic.

This will make sure that the inline schema defined in WSDL will customized as required.

<bindings 
 xmlns="http://java.sun.com/xml/ns/jaxb"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
 version="2.0">    
  <bindings wsdlLocation="b.wsdl">
    <globalBindings>
      <javaType name="java.util.Calendar" xmlType="xsd:dateTime"
        parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
        printMethod="javax.xml.bind.DatatypeConverter.printDate"
      />
     </globalBindings>  
  </bindings>
</bindings>

http://fusesource.com/docs/framework/2.1/jaxws/JAXWSCustomTypeMappingOverview.html

like image 113
kiri Avatar answered Nov 09 '22 11:11

kiri