wsconsume giving error: Part <PartName> in Message <MessageName> referenced Type <Type> can not be found in the schemas
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.1.1
- wsconsume (either through wsconsume.sh/bat, Ant, or Maven)
- CXF Web Service Framework
Issue
- When running wsconsume, I'm getting the following error:
Part <ServiceResult> in Message <{http://namespace}ServiceResponse> referenced Type <{http://namespace}ServiceResult> can not be found in the schemas
Resolution
Verify referenced type is declared in the schemas with particular attention paid to namespace declaration.
Root Cause
There are several causes of this issue, but one common one related to default namespaces. If you do not specify a namespace prefix on the type reference it will use the default namespace (defined with xmlns) on the closest parent element. For example:
<definitions name="ExampleService" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="https://example.com/">
<types>
<xs:schema xmlns:tns="https://example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="https://example.com/" version="1.0">
<xs:complexType name="ExampleResult">
.. removed details ..
</xs:complexType>
</xs:schema>
</types>
<message name="ExampleResponse">
<part name="ExampleResult" type="ExampleResult"/>
In this example, ExampleResult has the namespace "https://example.com/" as declared in the schema, but when referenced in ExampleResponse it has the namespace http://schemas.xmlsoap.org/wsdl/ because it does not have a prefix and the default namespace is declared with http://schemas.xmlsoap.org/wsdl/. It was probably intended to prefix the declaration or the default namespace is incorrect.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
