Simplejaxwsserviceexporter - Baseddress

Asked

Viewed 113 times

0

I created a web service with JAX-WS and used Spring to put it online and also to decrease the use of XML. Problem is that when I declare the Simplejaxwsserviceexporter in the Spring configuration file I have to put the attribute baseAddress that is the host, the default is localhost:8080 and when it is this way I cannot access the Webservice through another machine. Ex: I go on another machine and type the IP of mine and not access the Web Service on the port referred, now if I configure the baseAddress with my-ip:8080 I access from any machine and not access by localhost:8080/

If it was a study project I had no problem but I have to put in homologation and production and every time before generating the . War have change and put ip.

<?xml version="1.0" encoding="UTF-8"?><beans    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.2.xsd
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<tx:annotation-driven/>
<context:component-scan base-package="br" />
<context:annotation-config />

<bean name="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" scope="singleton">
    <property name="packagesToScan" value="br.com" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</prop>
            <prop key="hibernate.connection.url">$url</prop>
            <prop key="hibernate.connection.username">$user</prop>
            <prop key="hibernate.connection.password">$pass</prop>

            <prop key="hibernate.c3p0.min_size">5</prop>
            <prop key="hibernate.c3p0.max_size">20</prop>
            <prop key="hibernate.c3p0.timeout">86400</prop>
            <prop key="hibernate.c3p0.max_statements">0</prop>
            <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
            <prop key="hibernate.c3p0.idle_test_period">120</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager"  class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" /> 
</bean>

<bean id="messageDispatcherServlet" class="org.springframework.ws.transport.http.MessageDispatcherServlet">
</bean>

<!-- Localhost -->
<bean class= "org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
    <property name="baseAddress" value="http://localhost:7078/" />
</bean>

1 answer

1


I suggest using this setting:

dependency:

<dependency>
    <groupId>org.jvnet.jax-ws-commons.spring</groupId>
    <artifactId>jaxws-spring</artifactId>
    <version>1.9</version>
</dependency>

service configuration

<wss:binding url="/service/enderecoSeuServico">
    <wss:service>
        <ws:service bean="#seuBeanAnotadoCom @WebService" /> 
    </wss:service>
</wss:binding>

where the prefixes are:

xmlns:ws= "http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"

so no matter the baseAddress of your server

  • I already have her in pom.xml =/

  • then just replace your Simplejaxwsserviceexporter bean with bindings, I changed the answer with the prefix definition

  • And every time I add a new Web Service I’ll have to add in XML too, I’m running away from that rsrs. I’ll leave it as it is, I just change the address when generating the . War

Browser other questions tagged

You are not signed in. Login or sign up in order to post.