How to customize the schema inlined inside an imported WSDL
Asked Answered
G

2

5

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>
Griselgriselda answered 30/6, 2011 at 13:39 Comment(0)
G
2

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

Griselgriselda answered 1/7, 2011 at 9:6 Comment(1)
I was skeptical, but this worked perfectly for me when nothing else would. I used <serializable uid="1" /> instead of the <javaType> bit though.Domineer
S
0

Have you tried adding the following attributes to the <jaxws:bindings> element?

 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

and

 xmlns:xsd="http://www.w3.org/2001/XMLSchema"

You're referencing the xsd and wsdl namespaces in your xpath expression, but until you define the URI's for them, they won't match up with the URI's in the target documents.

Sophia answered 30/6, 2011 at 17:30 Comment(2)
FYI, I don't know anything about the technologies you're using other than XML and XPATH, but I didn't see any connection between the namespace prefixes in the XPATH and the URI's of the schemas used in the target XML, which is a red flag to me.Sophia
I have added the namespace prefixes by editing the question this also doesn't work. I am not using any other technology other than jaxws. Here I am trying to customize the generated code to use GregorianCalendar instead of XMLGregorianCalendar. I have used the same on imported schemas and it works but when it comes to inlined schema inside an imported WSDL(b.wsdl) it's not working:-(Griselgriselda

© 2022 - 2024 — McMap. All rights reserved.