views:

265

answers:

1

I have an xsd file Foo.xsd. I tried following ways to refer it in a WSDL file but it doesnt work.

1) placed the xsd file in local file system and imported it as

<xsd:import namespace="http://ws.test.com/" schemaLocation="file:///D:/wsdl/Foo.xsd"></xsd:import>

2) Placed the xsd file in web root folder and imported as

<xsd:import namespace="http://ws.test.com/" schemaLocation="http://localhost:8080/Xfire/Foo.xsd"&gt;&lt;/xsd:import&gt;

When I run the client I get null for the fields of response object. But this works when I embed the type definition inside the WSDL itself.

How do we specify the path to external xsds?

I am using xFire 1.2.6 for generating webservices. Client is generated using xFire WSGen ant task.

+2  A: 

The WSDL is accessed by HTTP from any host, so the client can neither access a file URL nor the localhost (which will be its own host, not your server). The best solution will be a relative path or server absolute path of the xsd file:

<xsd:import namespace="http://ws.test.com/" schemaLocation="../Foo.xsd"/>

<xsd:import namespace="http://ws.test.com/" schemaLocation="/myapp/Foo.xsd"/>

For the last one you need to know the context path of your webapp, so I would prefer the relative path.

Arne Burmeister
tried the relative path using schemaLocation="/xfire/Foo.xsd"org.codehaus.xfire.XFireRuntimeException: Couldn't find schema part: xFire 1.2.6 used for generating webservices.
Manoj
A relative path does not start with a /. Is /xfire the context path of your webapp?
Arne Burmeister