Hi,
You can do it like
<bean id="person" class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
<property name="dataSource" ref="moodleDB" />
</bean>
then in your jaxws:endpoint
<jaxws:endpoint id="HTTPEndpoint"
implementor="#person"
address="/PersonService"
...
This is the way to refer a spring managed-bean in your jaxws:endpoint
Freeman

Matteo Redaelli wrote:
Ciao

In beans.xml I have added the info about my db (<bean id="moodleDB" ...)

Now where do I have to insert the "dataSource" property I need in class
"org.apache.servicemix.samples.wsdl_first.PersonImpl"

I would add something like

                        <bean 
class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
                                <property name="dataSource" ref="moodleDB" />
                        </bean>

bit where?

Thanks in advanve

My beans.xml, generated by maven archetype is


<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:jaxws="http://cxf.apache.org/jaxws";
        xsi:schemaLocation="
                http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
                http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd
                http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd";>

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
    <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

<bean id="moodleDB" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/moodle" /> <property name="username" value="root" /> <property name="password" value="" /> </bean>
        <jaxws:endpoint id="HTTPEndpoint"
            implementor="org.apache.servicemix.samples.wsdl_first.PersonImpl"
            address="/PersonService"
            wsdlLocation="wsdl/person.wsdl"
            endpointName="e:soap"
            serviceName="s:PersonService"
            xmlns:e="http://servicemix.apache.org/samples/wsdl-first";
            xmlns:s="http://servicemix.apache.org/samples/wsdl-first";>
        </jaxws:endpoint>



Matteo Redaelli wrote:
Hello

In smx4 I'm tring to convert the JBI example cxf-wsdl-first-jdbc
(http://matteoredaelli.wordpress.com/2009/05/30/connecting-to-a-database-with-a-webservice-cxf-deployed-jbi-in-servicemix/)
with a similar OSGI project.

I created a project using

 mvn archetype:create \
        -DarchetypeGroupId=org.apache.servicemix.tooling \
        -DarchetypeArtifactId=servicemix-osgi-cxf-wsdl-first-archetype  \
        -DarchetypeVersion=2008.01-SNAPSHOT \
        -DgroupId=com.yourcompany \
        -DartifactId=test-wsdl-first-osgi \
        -Dversion=1.0-SNAPSHOT \

-DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository/

Than I added osgi wraps for spring-jdnc and mysql with

osgi/install  wrap mvn:org.springframework/spring-jdbc/2.5.6
osgi/install  wrap mvn:mysql/mysql-connector-java/5.0.8

[ 181] [Active     ] [       ] [   60] Spring JDBC (2.5.6)
[ 272] [Active     ] [       ] [   60]
mvn:mysql/mysql-connector-java/5.0.8

MY changes in pom.xml are:

                <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.0.8</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-jdbc</artifactId>
                        <version>2.5.6</version>
                </dependency>
                ...
                 <Import-Package>
                            ...
                            org.springframework.jdbc.datasource,
                            com.mysql.jdbc, *
                  </Import-Package>
                  ...
                  <DynamicImport-Package>*</DynamicImport-Package>

MY beans.xml
         ...
<bean id="moodleDB" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/moodle" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> ...


Questions:

1) how can load properly mysql jar in smx?

I have the error

s...@root:/> osgi/start 292
ERROR CommandLineExecutionFailed:
org.apache.geronimo.gshell.command.CommandException:
org.osgi.framework.BundleException: Unresolved constraint in bundle 292:
package; (package=com.mysql.jdbc)

In a camel tutorial I found

    <feature name="jdbc-driver">
        ...
<bundle>mvn:com.mysql.jdbc/com.springsource.com.mysql.jdbc/5.1.6</bundle>
    </feature>

but osgi/install  wrap
mvn:com.mysql.jdbc/com.springsource.com.mysql.jdbc/5.1.6 doesn't work


2) the file beans.xml generated by maven archetype is quite different from
the one of cxf-wsdl-first. where/how can I add the "property datasource" ?

I see

        <jaxws:endpoint id="HTTPEndpoint"
            implementor="org.apache.servicemix.samples.wsdl_first.PersonImpl"
            address="/PersonService"
            wsdlLocation="wsdl/person.wsdl"
            endpointName="e:soap"
            serviceName="s:PersonService"
            xmlns:e="http://servicemix.apache.org/samples/wsdl-first";
        xmlns:s="http://servicemix.apache.org/samples/wsdl-first"/>

Thanks in advance
Matteo




--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com

Reply via email to