开发者

Issue with a clientApplicationContext xml file

I'm running a tutorial I got off the web and I'm getting an error:

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. 

It failed with:

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

It's for Spring 2.5, Tomcat 7, Eclipse Helios and java 1.6.

All I did was change this value from port 9090 to 8080:

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

I have the file in two places: under java resources and also under src. I used the defaults for the app code as I just pulled it into my project and the port number is the only thing I changed, other than creating a new dynamic web project in eclipse.

In the main method here is the offending code:

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

There is an applicationContext.xml file under web-inf that I added my bean definition to:

<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="Defaul开发者_StackOverflowtOrderServicePort"/>
</bean>

Looks right, so what am I doing wrong here?


It tells you that it:

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

Can you access this WSDL from the browser?

Look at the setter of the WSDL:

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

There is no magic here => it expects a WSDL to be at that location.

You can publish WSDL dynamically:

<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>

or statically:

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

Read more about "Publishing the WSDL" and "Automatic WSDL exposure"


I think you should use class path prefix that should solve the problem, If you use class path prefix java run time will find the context file under src/main/resources

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜