I'm using Maven 3.0.3 and Spring 3.1.1.RELEASE. I would like to autowire a web service client, whose classes I'm generating with the jaxws-maven-plugin ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>${wsdl.url}</wsdlUrl>
</wsdlUrls>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<packageName>org.myco.myws</packageName>
</configuration>
</execution>
</executions>
</plugin>
However, I'm confused about how to setup my Spring applicaton context. I have
<bean id="organizationWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="org.myco.myws.OrganizationWebService" />
<property name="namespaceUri" value="http://myco.org/myws/" />
<property name="serviceName" value="api" />
<property name="endpointAddress" value="http://hbs-01.qa2.myco.cb:8443/bsg/myws/OrganizationService?WSDL" />
</bean>
But I get this error. Note the "related cause: WSDL Metadata not available to create the proxy". How do I configure this thing correctly?
java.lang.IllegalStateException: Failed to load ApplicationContext^M
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)^M
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)^M
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)^M
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)^M
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)^M
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)^M
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)^M
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)^M
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)^M
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)^M
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)^M
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)^M
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)^M
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)^M
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)^M
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)^M
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)^M
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)^M
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)^M
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)^M
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)^M
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)^M
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)^M
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)^M
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)^M
at java.lang.reflect.Method.invoke(Method.java:597)^M
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)^M
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)^M
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)^M
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)^M
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)^
...
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'organizationWebService' defined in class path resource [testAppContextHSQL.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy, either Service instance or ServiceEndpointInterface org.myco.myws.OrganizationWebService should have WSDL information
You are missing the WSDL document URL in your Spring configuration:
<bean id="organizationWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="org.myco.myws.OrganizationWebService" />
<property name="namespaceUri" value="http://myco.org/myws/" />
<property name="serviceName" value="api" />
<property name="endpointAddress" value="http://hbs-01.qa2.myco.cb:8443/bsg/myws/OrganizationService" />
<property name="wsdlDocumentUrl" value="classpath:org/myco/mywscampaignmonitor/mywscampaignmonitor.wsdl" />
</bean>
Use the configuration as above and it should work.
Faced with the same problem, it turned out, I was missing these depedencies:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.0.0</version>
</dependency>
Just adding them to my classpath solved the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.