开发者

How to specify schema location in an xsd file?

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"></xsd:import>

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 xFir开发者_运维百科e 1.2.6 for generating webservices. Client is generated using xFire WSGen ant task.


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 file path to the xsd file:

Relative path:

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

Absolute path:

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜