Weblogic Web Services With Spring Framework

Recently, I was trying to connect to a web service with the Spring Framework JaxRpcPortProxyFactoryBean. The web service and client code were generated with the weblogic servicegen and clientgen ant tasks respectively.

I found this example on the dev2dev site:
http://dev2dev.bea.com/pub/a/2005/09/spring_integration_weblogic_server.html?page=3

Unfortunately, it didn’t work for me. I spent almost an entire day trying to get it to work. So, in hopes of saving someone else some time, I’ve posted the correct way to make this work below. The example in the article is incorrect in one place. It uses the wsdlDocumentUrl attribute of the JaxRpcPortProxyFactoryBean. However, that attribute is a java.net.URL, not a String, so setting it with a string value will not work. The value I entered for the wsdDocumentlUrl had no effect. Instead, you need to set the wsdl URL on the Impl class generated by clientgen, by passing it into the constructor as seen in the second bean definition below.


<bean id="investorWebService"
        class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean" lazy-init="true">
   <property name="portName">
            <value>InvestorServicePort</value>
    </property>
    <property name="serviceInterface">
            <value>com.xxx.fmg.investorservice.common.ws.InvestorServicePort</value>
    </property>
    <property name="jaxRpcService">
            <ref bean="investorServiceImpl"/>
    </property>
</bean>

<!-- allows the jaxRpcService class to execute its constructor -->
<bean id="investorServiceImpl"
        class="com.xxx.fmg.investorservice.common.ws.InvestorService_Impl" lazy-init="true">
        <constructor -arg>
            <value>http://server:port/InvestorService/InvestorService?WSDL</value>
        </constructor>
</bean>

Spring Framework 2.0 is coming out in the next few months. Supposedly there are some great new Web Service tools in that release. If that’s the case we can stop using the web service tools provided by BEA.

3 Responses to “Weblogic Web Services With Spring Framework”

  1. Chris Says:

    Spring uses PropertyEditors to convert String arguments to their appropriate type.

    Your ServiceImpl implementation’s default constructor will provide the WSDL (_saved_wsdl.wsdl) to ServiceImpl. If the WSDL is accessible via a Classloader, supplying the WSDL URL to the implementation’s String constructor is not necessary.

    What problem(s) were you running into?

  2. Matt Luce Says:

    The problem that I had was that the wsdlDocumentUrl was not being used when I set it on the JaxRpcPortProxyFactoryBean. No matter what value I entered (even garbage value), it was ignored. It was using the default value in the WSDL, which is localhost:7001. I don’t want that value, so I needed to pass the wsdl url to the constructor of the ServiceImpl.

  3. Tim Says:

    Do you have a Java code example of how to use this once it’s injected? I tried this and keep getting a ClassCastException