You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Roman Sch�nbichler <ro...@matkovits.at> on 2007/11/12 14:04:36 UTC

WSDL2Java NullPointerException populateService

Hey Guys!

I'm stuck here trying to generate code out of my hand made wsdl file.
wsdl2java throws an exception:
[ERROR]
NullPointerException
at
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateServic
e(WSDL11ToAxisServiceBuilder.java:246)

The wsdl file looks like this:
(services.wsdl)
<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions  name="CalculableHouseholdService" 
	targetNamespace="http://webservice"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:tns="http://webservice">

	<wsdl:import namespace="http://webservice"
location="definitions/CalculableHouseholdService.wsdl"/>

	<wsdl:binding name="CalculableHouseholdServiceSoapBinding"
type="tns:CalculableHouseholdServicePortType">
		<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
		<wsdl:operation name="calculate">
			<soap:operation soapAction="tns:calculate"/>
			<wsdl:input>
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getInputObjects">
			<soap:operation soapAction="tns:getInputObjects"/>
			<wsdl:input>
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>

	<wsdl:service name="Calculable Household">
	<wsdl:documentation>Gets input objects from DB to the client, and
can calculate household objects </wsdl:documentation>
		<wsdl:port name="CalculabelHouseholdPort"
binding="CalculableHouseholdServiceSoapBinding">
			<soap:address
location="http://localhost:2345/axis2/services/CalculableHouseholdServ
ice"/>
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

(CalculableHouseholdService.wsdl)
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CalculableHouseholdService" 
	targetNamespace="http://webservice"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:tns="http://webservice">
	
	<wsdl:import namespace="http://webservice"
location="../schemas/household.xsd" />
	
	<wsdl:message name="calculateRequest">
		<wsdl:part name="parameters" element="tns:Household"/>
	</wsdl:message>

	<wsdl:message name="calculateResponse">
		<wsdl:part name="body" element="tns:Result"/>
	</wsdl:message>

	<wsdl:message name="getInputObjectsRequest"/>
	<wsdl:message name="getInputObjectsResponse">
		<wsdl:part name="parameters" element="tns:Household"/>
	</wsdl:message>
	
	<wsdl:portType name="CalculableHouseholdServicePortType">
		<wsdl:operation name="getInputObjects">
			<wsdl:input message="tns:getInputObjectsRequest"/>
			<wsdl:output message="tns:getInputObjectsResponse"/>
		</wsdl:operation>
		<wsdl:operation name="calculate">
			<wsdl:input message="tns:calculateRequest"/>
			<wsdl:output message="tns:calculateResponse"/>
		</wsdl:operation>		
	</wsdl:portType>
</wsdl:definitions>

(Houshold.xsd)
<?xml version="1.0" encoding="UTF-8"?>

<!-- New document created at Mon Nov 12 09:50:02 CET 2007 -->

<schema targetNamespace="http://webservice"
	xmlns="http://www.w3.org/2000/10/XMLSchema">
	<element name="Household">
		<complexType>
			<all>
				<element name="hid" type="positive-integer" min_occures="1"/>
				<element name="memberships" type="Membership" nillable="true"
min_occures="0" max_occures="unbounded"/>
			</all>
		</complexType>
	</element>
	<element name="Membership">
		<complexType>
			<all>
				<element name="mid" type="positive-integer" min_occures="1"/>
				<element name="person" type="Person" nillable="true"
minOccurs="0"/>
				<element name="first" type="date" nillable="true" minOccurs="0"/>
				<element name="last" type="date" nillable="true" minOccurs="0"/>
			</all>
		</complexType>
	</element>
	<element name="Person">
		<complexType>
			<all>
				<element name="pid" type="positive-integer" min_occures="1"/>
				<element name="lastname" type="string" nillable="true"
minOccurs="0"/>
				<element name="firstname" type="string" nillable="true"
minOccurs="0"/>
				<element name="title" type="string" nillable="true"
minOccurs="0"/>
				<element name="dateOfBirth" type="date" nillable="true"
minOccurs="0"/>
				<element name="female" type="boolean" nillable="true"
minOccurs="0"/>
			</all>
		</complexType>
	</element>
	<element name="Result">
		<complexType>
			<element name="result" type="positive-integer"/>
		</complexType>
	</element>
</schema>

I just can't find the error. Maybe I've got something wrong with the
namespaces.

I would be glad for some hints!

Greets
Roman


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: WSDL2Java NullPointerException populateService

Posted by Anne Thomas Manes <at...@gmail.com>.
I also found a number of errors in your schema.

1. You need to declare a namespace for your targetNamespace. You have
declared a default namespace ("http://www.w3.org/2000/10/XMLSchema"),
so any unqualified QNames refer to types in the schema namespace.
E.g.:

        <element name="Household">
               <complexType>
                       <all>
                               <element name="hid"
type="positive-integer" min_occures="1"/>
                               <element name="memberships"
type="Membership" nillable="true"
                                   min_occures="0" max_occures="unbounded"/>
                       </all>
               </complexType>
       </element>

This tells the system to look for the "Membership" type in the schema
namespace rather than the "http://webservice" namespace. You need to
declare the targetNamespace and qualify these type references, e.g.:

<schema targetNamespace="http://webservice"
       xmlns="http://www.w3.org/2000/10/XMLSchema"
       xmlns:tns="http://webservice">

        <element name="Household">
               <complexType>
                       <all>
                               <element name="hid"
type="positive-integer" minOccurs="1"/>
                               <element name="memberships"
type="tns:Membership" nillable="true"
                                   minOccurs="0" maxOccurs="unbounded"/>
                       </all>
               </complexType>
       </element>

2. You misspelled the "occurs" attributes:
"minOccurs" and "maxOccurs" versus "min_occures" and "max_occures"

3. You misspelled the positive integer schema type:
"positiveInteger" versus "positive-integer"

There may be more errors -- I strongly recommend that you validate the schema.

Anne

Anne

On Nov 12, 2007 3:37 PM, Anne Thomas Manes <at...@gmail.com> wrote:
> Roman,
>
> You shouldn't use wsdl:import to import an XSD file.
>
> Change this:
>
>        <wsdl:import namespace="http://webservice"
> location="../schemas/household.xsd" />
>
> to this:
>
>        <wsdl:types>
>          <xsd:schema targetNamespace="http://webservice"
>             xmlns:xsd=""http://www.w3.org/2000/10/XMLSchema">
>             <xsd:import namespace="http://webservice"
>                schemaLocation="../schemas/household.xsd" />
>             </xsd:import>
>          </xsd:schema>
>        </wsdl:types>
>
>
> In any case, Axis2 should not generate an NPE, so please also file a
> JIRA and include your WSDLs and schema.
>
> Anne
>
> On Nov 12, 2007 8:04 AM, Roman Schönbichler
>
> <ro...@matkovits.at> wrote:
> > Hey Guys!
> >
> > I'm stuck here trying to generate code out of my hand made wsdl file.
> > wsdl2java throws an exception:
> > [ERROR]
> > NullPointerException
> > at
> > org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateServic
> > e(WSDL11ToAxisServiceBuilder.java:246)
> >
> > The wsdl file looks like this:
> > (services.wsdl)
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <wsdl:definitions  name="CalculableHouseholdService"
> >         targetNamespace="http://webservice"
> >         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> >         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> >         xmlns:tns="http://webservice">
> >
> >         <wsdl:import namespace="http://webservice"
> > location="definitions/CalculableHouseholdService.wsdl"/>
> >
> >         <wsdl:binding name="CalculableHouseholdServiceSoapBinding"
> > type="tns:CalculableHouseholdServicePortType">
> >                 <soap:binding style="document"
> > transport="http://schemas.xmlsoap.org/soap/http"/>
> >                 <wsdl:operation name="calculate">
> >                         <soap:operation soapAction="tns:calculate"/>
> >                         <wsdl:input>
> >                                 <soap:body use="literal"/>
> >                         </wsdl:input>
> >                         <wsdl:output>
> >                                 <soap:body use="literal"/>
> >                         </wsdl:output>
> >                 </wsdl:operation>
> >                 <wsdl:operation name="getInputObjects">
> >                         <soap:operation soapAction="tns:getInputObjects"/>
> >                         <wsdl:input>
> >                                 <soap:body use="literal"/>
> >                         </wsdl:input>
> >                         <wsdl:output>
> >                                 <soap:body use="literal"/>
> >                         </wsdl:output>
> >                 </wsdl:operation>
> >         </wsdl:binding>
> >
> >         <wsdl:service name="Calculable Household">
> >         <wsdl:documentation>Gets input objects from DB to the client, and
> > can calculate household objects </wsdl:documentation>
> >                 <wsdl:port name="CalculabelHouseholdPort"
> > binding="CalculableHouseholdServiceSoapBinding">
> >                         <soap:address
> > location="http://localhost:2345/axis2/services/CalculableHouseholdServ
> > ice"/>
> >                 </wsdl:port>
> >         </wsdl:service>
> > </wsdl:definitions>
> >
> > (CalculableHouseholdService.wsdl)
> > <?xml version="1.0" encoding="UTF-8"?>
> > <wsdl:definitions name="CalculableHouseholdService"
> >         targetNamespace="http://webservice"
> >         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> >         xmlns:tns="http://webservice">
> >
> >         <wsdl:import namespace="http://webservice"
> > location="../schemas/household.xsd" />
> >
> >         <wsdl:message name="calculateRequest">
> >                 <wsdl:part name="parameters" element="tns:Household"/>
> >         </wsdl:message>
> >
> >         <wsdl:message name="calculateResponse">
> >                 <wsdl:part name="body" element="tns:Result"/>
> >         </wsdl:message>
> >
> >         <wsdl:message name="getInputObjectsRequest"/>
> >         <wsdl:message name="getInputObjectsResponse">
> >                 <wsdl:part name="parameters" element="tns:Household"/>
> >         </wsdl:message>
> >
> >         <wsdl:portType name="CalculableHouseholdServicePortType">
> >                 <wsdl:operation name="getInputObjects">
> >                         <wsdl:input message="tns:getInputObjectsRequest"/>
> >                         <wsdl:output message="tns:getInputObjectsResponse"/>
> >                 </wsdl:operation>
> >                 <wsdl:operation name="calculate">
> >                         <wsdl:input message="tns:calculateRequest"/>
> >                         <wsdl:output message="tns:calculateResponse"/>
> >                 </wsdl:operation>
> >         </wsdl:portType>
> > </wsdl:definitions>
> >
> > (Houshold.xsd)
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <!-- New document created at Mon Nov 12 09:50:02 CET 2007 -->
> >
> > <schema targetNamespace="http://webservice"
> >         xmlns="http://www.w3.org/2000/10/XMLSchema">
> >         <element name="Household">
> >                 <complexType>
> >                         <all>
> >                                 <element name="hid" type="positive-integer" min_occures="1"/>
> >                                 <element name="memberships" type="Membership" nillable="true"
> > min_occures="0" max_occures="unbounded"/>
> >                         </all>
> >                 </complexType>
> >         </element>
> >         <element name="Membership">
> >                 <complexType>
> >                         <all>
> >                                 <element name="mid" type="positive-integer" min_occures="1"/>
> >                                 <element name="person" type="Person" nillable="true"
> > minOccurs="0"/>
> >                                 <element name="first" type="date" nillable="true" minOccurs="0"/>
> >                                 <element name="last" type="date" nillable="true" minOccurs="0"/>
> >                         </all>
> >                 </complexType>
> >         </element>
> >         <element name="Person">
> >                 <complexType>
> >                         <all>
> >                                 <element name="pid" type="positive-integer" min_occures="1"/>
> >                                 <element name="lastname" type="string" nillable="true"
> > minOccurs="0"/>
> >                                 <element name="firstname" type="string" nillable="true"
> > minOccurs="0"/>
> >                                 <element name="title" type="string" nillable="true"
> > minOccurs="0"/>
> >                                 <element name="dateOfBirth" type="date" nillable="true"
> > minOccurs="0"/>
> >                                 <element name="female" type="boolean" nillable="true"
> > minOccurs="0"/>
> >                         </all>
> >                 </complexType>
> >         </element>
> >         <element name="Result">
> >                 <complexType>
> >                         <element name="result" type="positive-integer"/>
> >                 </complexType>
> >         </element>
> > </schema>
> >
> > I just can't find the error. Maybe I've got something wrong with the
> > namespaces.
> >
> > I would be glad for some hints!
> >
> > Greets
> > Roman
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: WSDL2Java NullPointerException populateService

Posted by Anne Thomas Manes <at...@gmail.com>.
Roman,

You shouldn't use wsdl:import to import an XSD file.

Change this:

       <wsdl:import namespace="http://webservice"
location="../schemas/household.xsd" />

to this:

       <wsdl:types>
         <xsd:schema targetNamespace="http://webservice"
            xmlns:xsd=""http://www.w3.org/2000/10/XMLSchema">
            <xsd:import namespace="http://webservice"
               schemaLocation="../schemas/household.xsd" />
            </xsd:import>
         </xsd:schema>
       </wsdl:types>


In any case, Axis2 should not generate an NPE, so please also file a
JIRA and include your WSDLs and schema.

Anne

On Nov 12, 2007 8:04 AM, Roman Schönbichler
<ro...@matkovits.at> wrote:
> Hey Guys!
>
> I'm stuck here trying to generate code out of my hand made wsdl file.
> wsdl2java throws an exception:
> [ERROR]
> NullPointerException
> at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateServic
> e(WSDL11ToAxisServiceBuilder.java:246)
>
> The wsdl file looks like this:
> (services.wsdl)
> <?xml version="1.0" encoding="UTF-8"?>
>
> <wsdl:definitions  name="CalculableHouseholdService"
>         targetNamespace="http://webservice"
>         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>         xmlns:tns="http://webservice">
>
>         <wsdl:import namespace="http://webservice"
> location="definitions/CalculableHouseholdService.wsdl"/>
>
>         <wsdl:binding name="CalculableHouseholdServiceSoapBinding"
> type="tns:CalculableHouseholdServicePortType">
>                 <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>                 <wsdl:operation name="calculate">
>                         <soap:operation soapAction="tns:calculate"/>
>                         <wsdl:input>
>                                 <soap:body use="literal"/>
>                         </wsdl:input>
>                         <wsdl:output>
>                                 <soap:body use="literal"/>
>                         </wsdl:output>
>                 </wsdl:operation>
>                 <wsdl:operation name="getInputObjects">
>                         <soap:operation soapAction="tns:getInputObjects"/>
>                         <wsdl:input>
>                                 <soap:body use="literal"/>
>                         </wsdl:input>
>                         <wsdl:output>
>                                 <soap:body use="literal"/>
>                         </wsdl:output>
>                 </wsdl:operation>
>         </wsdl:binding>
>
>         <wsdl:service name="Calculable Household">
>         <wsdl:documentation>Gets input objects from DB to the client, and
> can calculate household objects </wsdl:documentation>
>                 <wsdl:port name="CalculabelHouseholdPort"
> binding="CalculableHouseholdServiceSoapBinding">
>                         <soap:address
> location="http://localhost:2345/axis2/services/CalculableHouseholdServ
> ice"/>
>                 </wsdl:port>
>         </wsdl:service>
> </wsdl:definitions>
>
> (CalculableHouseholdService.wsdl)
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="CalculableHouseholdService"
>         targetNamespace="http://webservice"
>         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>         xmlns:tns="http://webservice">
>
>         <wsdl:import namespace="http://webservice"
> location="../schemas/household.xsd" />
>
>         <wsdl:message name="calculateRequest">
>                 <wsdl:part name="parameters" element="tns:Household"/>
>         </wsdl:message>
>
>         <wsdl:message name="calculateResponse">
>                 <wsdl:part name="body" element="tns:Result"/>
>         </wsdl:message>
>
>         <wsdl:message name="getInputObjectsRequest"/>
>         <wsdl:message name="getInputObjectsResponse">
>                 <wsdl:part name="parameters" element="tns:Household"/>
>         </wsdl:message>
>
>         <wsdl:portType name="CalculableHouseholdServicePortType">
>                 <wsdl:operation name="getInputObjects">
>                         <wsdl:input message="tns:getInputObjectsRequest"/>
>                         <wsdl:output message="tns:getInputObjectsResponse"/>
>                 </wsdl:operation>
>                 <wsdl:operation name="calculate">
>                         <wsdl:input message="tns:calculateRequest"/>
>                         <wsdl:output message="tns:calculateResponse"/>
>                 </wsdl:operation>
>         </wsdl:portType>
> </wsdl:definitions>
>
> (Houshold.xsd)
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- New document created at Mon Nov 12 09:50:02 CET 2007 -->
>
> <schema targetNamespace="http://webservice"
>         xmlns="http://www.w3.org/2000/10/XMLSchema">
>         <element name="Household">
>                 <complexType>
>                         <all>
>                                 <element name="hid" type="positive-integer" min_occures="1"/>
>                                 <element name="memberships" type="Membership" nillable="true"
> min_occures="0" max_occures="unbounded"/>
>                         </all>
>                 </complexType>
>         </element>
>         <element name="Membership">
>                 <complexType>
>                         <all>
>                                 <element name="mid" type="positive-integer" min_occures="1"/>
>                                 <element name="person" type="Person" nillable="true"
> minOccurs="0"/>
>                                 <element name="first" type="date" nillable="true" minOccurs="0"/>
>                                 <element name="last" type="date" nillable="true" minOccurs="0"/>
>                         </all>
>                 </complexType>
>         </element>
>         <element name="Person">
>                 <complexType>
>                         <all>
>                                 <element name="pid" type="positive-integer" min_occures="1"/>
>                                 <element name="lastname" type="string" nillable="true"
> minOccurs="0"/>
>                                 <element name="firstname" type="string" nillable="true"
> minOccurs="0"/>
>                                 <element name="title" type="string" nillable="true"
> minOccurs="0"/>
>                                 <element name="dateOfBirth" type="date" nillable="true"
> minOccurs="0"/>
>                                 <element name="female" type="boolean" nillable="true"
> minOccurs="0"/>
>                         </all>
>                 </complexType>
>         </element>
>         <element name="Result">
>                 <complexType>
>                         <element name="result" type="positive-integer"/>
>                 </complexType>
>         </element>
> </schema>
>
> I just can't find the error. Maybe I've got something wrong with the
> namespaces.
>
> I would be glad for some hints!
>
> Greets
> Roman
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org