Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsdl files fail to load if they contain schemas that have complexType elements with restriction elements that reference built in types #180

Closed
longsonr opened this issue Mar 26, 2015 · 13 comments
Labels
Milestone

Comments

@longsonr
Copy link

The presence of a schema containing a complexType element that has a restriction element child with a base of anyType, boolean or string or other built in primitive type causes membrane to fail to start. If the schema is moved to an external file and imported into the wsdl then it works as expected.

Having a restriction element as a child of a simpleType seems to work OK.

Caused by: org.xml.sax.SAXParseException; systemId: file:///membrane-service-proxy-4.0.17/examples/validation/soap-Proxy/test.wsdl; lineNumber: 4; columnNumber: 41; src-resolve.4.1: Error resolving component 'anyType'. It was detected that 'anyType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///membrane-service-proxy-4.0.17/examples/validation/soap-Proxy/test.wsdl'. If 'anyType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'anyType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///membrane-service-proxy-4.0.17/examples/validation/soap-Proxy/test.wsdl'.

Consider this schema (schema.xsd)

<schema targetNamespace="http://www.example.com/IPO"
                attributeFormDefault="unqualified"
                elementFormDefault="unqualified"
        xmlns="http://www.w3.org/2001/XMLSchema">

<!-- this is OK -->
  <simpleType name="SKU2">
    <restriction base="string"/>
  </simpleType>

<!-- as is this externally -->
  <complexType name="SKU">
    <complexContent>
      <restriction base="anyType"/>
    </complexContent>
  </complexType>

</schema>

If I embed it into test.wsdl then membrane won't start. If I import it instead it's ok (adjust the data below to uncomment the import and comment the embedded schema to test).

<definitions name="HelloService"
   targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <types>

<!--
     <import namespace="http://www.example.com/IPO" schemaLocation="schema.xsd"/>
-->

    <schema targetNamespace="http://www.example.com/IPO"
                        attributeFormDefault="unqualified"
                elementFormDefault="unqualified"
            xmlns="http://www.w3.org/2001/XMLSchema">

<!-- this is OK too -->
      <simpleType name="SKU2">
        <restriction base="string"/>
      </simpleType>

<!-- but this is not! -->
      <complexType name="SKU">
        <complexContent>
          <restriction base="anyType"/>
        </complexContent>
      </complexType>

   </schema>

   </types>

   <!-- all of this is boilerplate to make the wsdl syntactically correct -->
   <message name="SayHelloRequest">
      <part name="firstName" type="SKU"/>
   </message>

   <message name="SayHelloResponse">
      <part name="greeting" type="string"/>
   </message>

   <portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name="Hello_Binding" type="tns:Hello_PortType">
      <soap:binding style="rpc"
         transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sayHello">
         <soap:operation soapAction="sayHello"/>
         <input>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </input>

         <output>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </output>
      </operation>
   </binding>

   <service name="Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding="tns:Hello_Binding" name="Hello_Port">
         <soap:address
            location="http://www.examples.com/SayHello/" />
      </port>
   </service>
</definitions>

proxies.xml

<spring:beans xmlns="http://membrane-soa.org/proxies/1/"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd">

    <router>
        <soapProxy port="20009" wsdl="test.wsdl">
                    <validator />
                </soapProxy>
    </router>
</spring:beans>
@longsonr longsonr changed the title wsdl files fail to load if they contain schemas that have complexType with restriction elements that reference built in types wsdl files fail to load if they contain schemas that have complexType elements with restriction elements that reference built in types Mar 26, 2015
@predic8
Copy link
Member

predic8 commented Mar 26, 2015

@longsonr can you please attach the WSDL that causes the error here? It will be much easy to locate the error. Thx

@longsonr
Copy link
Author

@predic8 predic8 added the bug label Mar 30, 2015
@predic8 predic8 added this to the 4.1.0 milestone Mar 30, 2015
@predic8
Copy link
Member

predic8 commented Mar 30, 2015

Needs to be fixed in soa-model dependency. We should upgrade soa-model to version 1.5.0 and test if it is also affected by this bug.

@predic8
Copy link
Member

predic8 commented Mar 30, 2015

4.0.19 also fixed this Issue. Thx @rrayst , and thx to @longsonr for the detailed report

@predic8 predic8 closed this as completed Mar 30, 2015
@longsonr
Copy link
Author

This does not appear to be fixed in 4.0.19. My testcase fails on the 4.0.19 I've just downloaded.

@predic8
Copy link
Member

predic8 commented Mar 30, 2015

Strange, just tested using your test.wsdl

@longsonr
Copy link
Author

Using the filebin test.wsdl I get this...

14:55:52,161 INFO Router:247 - Starting Membrane Service Proxy 4.0.19
org.springframework.context.ApplicationContextException: Failed to start bean 'router'; nested exception is java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl; lineNumber: 4; columnNumber: 41; src-resolve.4.1: Error resolving component 'anyType'. It was detected that 'anyType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'. If 'anyType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'anyType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'.
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:170)
at org.springframework.context.support.DefaultLifecycleProcessor.access$1(DefaultLifecycleProcessor.java:154)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:339)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143)
at org.springframework.context.support.DefaultLifecycleProcessor.start(DefaultLifecycleProcessor.java:89)
at org.springframework.context.support.AbstractApplicationContext.start(AbstractApplicationContext.java:1259)
at com.predic8.membrane.core.Router.init(Router.java:138)
at com.predic8.membrane.core.RouterCLI.main(RouterCLI.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.predic8.membrane.core.Starter.main(Starter.java:26)
Caused by: java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl; lineNumber: 4; columnNumber: 41; src-resolve.4.1: Error resolving component 'anyType'. It was detected that 'anyType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'. If 'anyType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'anyType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'.
at com.predic8.membrane.core.Router.start(Router.java:270)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:167)
... 12 more
Caused by: org.xml.sax.SAXParseException; systemId: file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl; lineNumber: 4; columnNumber: 41; src-resolve.4.1: Error resolving component 'anyType'. It was detected that 'anyType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'. If 'anyType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'anyType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'.

@predic8
Copy link
Member

predic8 commented Mar 30, 2015

It works when you leave the interceptor out. The error is from the SAX parser used for the validation. And maybe the SAX parser is right. Have a careful look at the error message:

It was detected that 'anyType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///Users/bjss/membrane-service-proxy-4.0.19/examples/validation/soap-Proxy/test.wsdl'. If 'anyType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'anyType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///Users/bjss/membrane-

@longsonr
Copy link
Author

If I add in an <import> tag without a namespace then I either get a NullPointerException (issue 179) if I leave the schemaLocation out or

Caused by: com.predic8.soamodel.WrongGrammarException: Expected root element '{http://www.w3.org/2001/XMLSchema}schema' for the schema document but was '{http://schemas.xmlsoap.org/wsdl/}definitions'.

if I add <import schemaLocation="test.wsdl"/>

Note that anyType is a built in type (http://www.w3.org/TR/xmlschema-0/#anyType) so I don't see why it should need importing in the first place.

@predic8
Copy link
Member

predic8 commented Mar 31, 2015

@longsonr I found the bug in the SOA Model and fixed it. Can I add your test.wsdl to the project as a test resource to prevent regression?

I will push the changes to the soa-model git as version 1.5.1 and send you a copy of the jar. You can substitute the JAR in the lib folder of Membrane to fix your installation. The next bugfix release of Membrane will contain the fix.

@predic8 predic8 reopened this Mar 31, 2015
@longsonr
Copy link
Author

Feel free to use my testcase in this bug. If you check in the soa-model changes I can build it from https://github.com/membrane/soa-model.

predic8 added a commit to membrane/soa-model that referenced this issue Mar 31, 2015
Implemented support for complexContent/restriction
Fixed: membrane/api-gateway#180

SchemaCreator:
Added support for complexContent/@mixed

Added support for anyType restriction
@predic8
Copy link
Member

predic8 commented Mar 31, 2015

@longsonr thx for the testcase I added it to the project. The modifications are pushed and taged as 1.5.1

@longsonr
Copy link
Author

fix confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants