2011-10-11 71 views
1

我跑的教程我下了網,我得到一個錯誤:問題與clientApplicationContext xml文件

org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'orderService' defined in 
    class path resource [clientApplicationContext.xml]: 
    Invocation of init method failed; 
    nested exception is javax.xml.ws.WebServiceException: 
    Failed to access the WSDL at: http://localhost:8080/services/order?WSDL. 

它失敗:

http://localhost:8080/services/order?WSDL. 

這對Spring 2.5的,Tomcat 7,Eclipse Helios和java 1.6。

我所做的只是從端口9090將此值更改爲8080:

<property name="wsdlDocumentUrl" 
      value="http://localhost:8080/services/order?WSDL"/> 

我在兩個地方的文件:在java的資源,也src下。我使用應用程序代碼的默認值,因爲我只是將它拖入我的項目中,並且端口號是我更改的唯一的東西,除了在eclipse中創建新的動態Web項目。

在這裏的主要方法是有問題的代碼:

ApplicationContext ctx = 
      new ClassPathXmlApplicationContext("clientApplicationContext.xml"); 

有WEB-INF下的applicationContext.xml文件,我將我的bean定義到:

<bean id="orderService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean" > 
    <property name="serviceInterface" value="com.javacoda.jaxws.order.client.OrderService"/> 
    <property name="wsdlDocumentUrl" value="http://localhost:8080/services/order?WSDL"/> 
    <property name="namespaceUri" value="com.javacoda.jaxws.order"/> 
    <property name="serviceName" value="DefaultOrderServiceService"/> 
    <property name="portName" value="DefaultOrderServicePort"/> 
</bean> 

看起來正確,所以我在這裏做錯了什麼?

+0

如果我得到它,正確的XML被稱爲(否則它會抱怨端口9090失敗)。我的下一個問題是:在這個地址是否真的有WSDL? – ptyx

+0

當我運行這個URL:http:// localhost:8080/services/order?WSDL與服務器運行我得到一個404錯誤,所以有些東西沒有設置正確。在另一個教程中,我不得不首先發布wsdl,並且當我指出wsdl出現的url時。未找到文件是根本原因。 –

回答

2

它會告訴你,它的類路徑前綴:

Failed to access the WSDL at: http://localhost:8080/services/order?WSDL 

您可以從瀏覽器訪問該WSDL?

考慮WSDL的二傳手:

/** 
* Set the URL of the WSDL document that describes the service. 
*/ 
public void setWsdlDocumentUrl(URL wsdlDocumentUrl) { 
    this.wsdlDocumentUrl = wsdlDocumentUrl; 
} 

有沒有神奇的在這裏=>預計一個WSDL是在那個位置。

可以動態發佈WSDL:

<sws:dynamic-wsdl id="holiday"               
    portTypeName="HumanResource"               
    locationUri="/holidayService/"              
    targetNamespace="http://mycompany.com/hr/definitions">        
    <sws:xsd location="/WEB-INF/hr.xsd"/>             
</sws:dynamic-wsdl> 

或靜態:

<sws:static-wsdl id="orders" location="/WEB-INF/wsdl/orders.wsdl"/> 

瞭解更多關於 「Publishing the WSDL」 和 「Automatic WSDL exposure

+0

不,當我有tomcat的時候它沒有找到wsdl。 –

+0

那麼如何將WSDL導出爲首先位於「http:// localhost:8080/services/order?WSDL」? – tolitius

+0

我沒有那樣做。所以我必須爲此做一些發佈?這是基本的東西,但我現在只是從頭開始設置jax-ws。我做了2個教程,他們有一個創建wsdl的發佈類。那麼導出wsdl的正確方法是什麼?對新手問題抱歉。 –

0

我認爲你應該使用應該解決的問題,如果你使用的類路徑前綴的Java運行時會發現在src /主/資源上下文文件

ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:clientApplicationContext.xml") 
+0

這沒有奏效。我不相信這是一個類路徑問題。 –