2011-11-29 30 views
2

我從現有的WSDL和XSD文件在開發Java技術的Web服務。該Web服務正在與具有以「java:」開頭的命名空間的現有客戶端應用程序targetNamespace =「java:com.mycompany.project」我無法更改客戶端使用的名稱空間。我使用NetBeans作爲IDE,它接受WSDL和XSD文件,通過jax-ws自動生成類。生成Web服務Java類套餐命名空間不同從WSDL和XSD文件

因爲名稱空間以「java:」開頭,所以應用程序服務器(我當前使用Glassfish,但可能使用其他服務器)拒絕部署代碼,因爲自定義程序包不能位於「java」下。包。錯誤是:

Error occurred during deployment: Exception while deploying the app [MyWebService] : Prohibited package name: java.com.mycompany.projecta. Please see server.log for more details. 
/NetBeansProjects/MyWebService/nbproject/build-impl.xml:288: 
The module has not been deployed. 
      at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210) 
      at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106) 
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) 
      at sun.reflect.GeneratedMethodAccessor488.invoke(Unknown Source) 
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
      at java.lang.reflect.Method.invoke(Method.java:597) 
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
      at org.apache.tools.ant.Task.perform(Task.java:348) 
      at org.apache.tools.ant.Target.execute(Target.java:390) 
      at org.apache.tools.ant.Target.performTasks(Target.java:411) 
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) 
      at org.apache.tools.ant.Project.executeTarget(Project.java:1368) 
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
      at org.apache.tools.ant.Project.executeTargets(Project.java:1251) 
      at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284) 
      at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539) 
      at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153) 

要解決這個問題,我想修改的WSDL和XSD文件在服務器端在不同的包創建自動生成的類。我增加了以下的WSDL:

<definitions... > 
    ... 
    <jaxws:bindings> 
     <jaxws:package name="com.mycompany.projecta"/> 
    </jaxws:bindings> 
</definitions> 

現在有些類是在「com.mycompany.projecta」包內產生的,但大多數,都沒有。我試圖添加...

<xsd:schemaBindings> 
    <xsd:package name="com.mycompany.projecta" /> 
</xsd:schemaBindings> 

...元素,但它們似乎不起作用。他們被添加到「XSD:模式> XSD:標註」在WSDL中。我已經在話題看了網上很多資料,並試圖其他替代方案,但我還沒有成功。

能否請您給我一些指導或洞察力,以什麼我可能是做錯了,所以我可以生成我的課在「com.mycompany.projecta」包,並與我的項目繼續前進?

謝謝!

回答

1

我相信我已經解決了我的問題。我解開一切之上,並添加了一個「一攬子」的屬性,以我的任務,我JAXWS-build.xml文件(我使用Ant來構建項目):

<wsimport package="com.mycompany.projecta" ... >

這產生下的所有類「com.mycompany.projecta」。

我要補充的是,我發現這是一個選項,通過閱讀:

http://jax-ws.java.net/nonav/2.1.1/docs/wsimportant.html