Results 1 to 4 of 4

Thread: Automatically generated WSDL without targetNamespace

  1. #1

    Default Automatically generated WSDL without targetNamespace

    Is it possible to use the XsdBasedSoap11Wsdl4jDefinitionBuilder for an XSD document that does not have a targetNamespace defined? I have over 100 legacy APIs that I need to expose as web services, and each API has its own schema similar to the following:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <xsd:element name="Pref1bs1ListCodeValuesT">
      <xsd:complexType>
       <xsd:choice>
    
        <xsd:element name="request">
         <xsd:complexType>
          <xsd:sequence>
           <xsd:element name="ImportIref1Interface">
    I defined the following in the spring application context file:

    Code:
    	<bean id="pref1bs1ListCodeValuesTWsdl" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
    		<property name="builder">
    			<bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
    				<property name="schema" value="/wsdl/Pref1bs1ListCodeValuesT.xsd" />
    				<property name="portTypeName" value="Pref1bs1ListCodeValuesT" />
    				<property name="schemaPrefix" value="tns" />
    				<property name="locationUri" value="/services" />
    			</bean>
    		</property>
    	</bean>
    But I am getting the following exception:

    Code:
    ---- Begin backtrace for Nested Throwables
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pref1bs1ListCodeValuesTWsdl' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Cannot create inner bean 'org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder#535c535c' of type [org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder] while setting bean property 'builder'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder#535c535c' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: schema document has no targetNamespace
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder#535c535c' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: schema document has no targetNamespace
    Caused by: java.lang.IllegalArgumentException: schema document has no targetNamespace
    	at org.springframework.util.Assert.hasLength(Assert.java:135)
    	at org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder.parseSchema(XsdBasedSoap11Wsdl4jDefinitionBuilder.java:188)
    	at org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder.afterPropertiesSet(XsdBasedSoap11Wsdl4jDefinitionBuilder.java:172)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
    Shannon Kendrick

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    I'm afraid that's not possible, since the WSDL needs to refer to elements in the Schema, based on the target namespace. So it's not as much a Spring-WS issue, but more a WSDL issue. What should the generated WSDL look like?
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3

    Default

    Is it possible to set the targetNamespace programatically instead of XsdSchemaHelper throwing an exception in XsdSchemaHelper when a targetNamespace is not found?

    Code:
        public XsdSchemaHelper(Resource schemaResource) throws ParserConfigurationException, IOException, SAXException {
            Assert.notNull(schemaResource, "schema must not be empty or null");
            Assert.isTrue(schemaResource.exists(), "schema \"" + schemaResource + "\" does not exit");
            this.schemaResource = schemaResource;
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(schemaResource));
            schemaElement = schemaDocument.getDocumentElement();
            Assert.isTrue(SCHEMA_NAME.getLocalPart().equals(schemaElement.getLocalName()),
                    "schema document root element has invalid local name : [" + schemaElement.getLocalName() +
                            "] instead of [schema]");
            Assert.isTrue(SCHEMA_NAME.getNamespaceURI().equals(schemaElement.getNamespaceURI()),
                    "schema document root element has invalid namespace uri: [" + schemaElement.getNamespaceURI() +
                            "] instead of [" + SCHEMA_NAME.getNamespaceURI() + "]");
            Assert.hasLength(getTargetNamespace(), "schema [" + schemaResource + "] has no targetNamespace");
        }
    Shannon Kendrick

  4. #4
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    I suppose so. But I'm not sure whether the resulting WSDL is very interoperable. If you create a JIRA issue, I will look at it.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •