2010-12-14 77 views
0

Bonjour tout d'abord désolé pour mon mauvais anglais.Communication SOAP sans Tomcat ou Axis

Je développe avec Eclipse. En tant que plate-forme cible, j'utilise l'espadon par défaut. Je veux utiliser SOAP comme protocole mais sans un kit exta comme Tomcat. J'ai écrit paar de fichiers WSDL. Avec Swordfish j'ai construit un fournisseur et un consommateur. Cela fonctionne très bien pour le premier. Mais après un certain temps, l'interface de protocoll est nulle, parce que la session n'est pas valide. L'espadon rend toute connexion automatique, et je n'avais pas trouvé comment je me connectais à mon interface manuellement. (Espadon utilisant OSGI) Comment puis-je réessayer une connexion manuellement?

est un code ici qui sera utile

import java.util.Timer; 
import java.util.TimerTask; 

import org.apache.commons.logging.Log; 
import org.apache.commons.logging.LogFactory; 
import org.springframework.beans.factory.InitializingBean; 
import org.springframework.util.Assert; 
import org.iecimpl.serverserverprotocoll.ServerServerProtocoll; 

public class ServerServerProtocollClientInvoker implements InitializingBean { 
    private static final Log LOG = LogFactory.getLog(ServerServerProtocollClientInvoker.class); 
private Integer delayBeforeSending = 5000; 
private ServerServerProtocoll serverServerProtocoll; 
public ServerServerProtocoll getServerServerProtocoll() { 
    return serverServerProtocoll; 
} 

public void setServerServerProtocoll(ServerServerProtocoll serverServerProtocoll) { 
    this.serverServerProtocoll = serverServerProtocoll; 
} 

public Integer getDelayBeforeSending() { 
    return delayBeforeSending; 
} 

public void setDelayBeforeSending(Integer delayBeforeSending) { 
    this.delayBeforeSending = delayBeforeSending; 
} 

public void afterPropertiesSet() throws Exception { 
    Assert.notNull(serverServerProtocoll); 
    Timer timer = new Timer(); 
     timer.schedule(new TimerTask() { 
      @Override 
      public void run() { 
       try { 
        performRequest(); 
       } catch (Exception ex) { 
        throw new RuntimeException(ex); 
       } 
      } 


     }, delayBeforeSending); 
    } 
private void performRequest() { 
    LOG.info("Performing invocation on ..."); 
    /*Implementation*/ 
    clienttest.testclienttest(serverServerProtocoll); 
    LOG.info("Result of runing is...."); 
} 
} 

fichier xml:

xml under META-INF/spring/jaxws-consumer.xml 
<?xml version="1.0" encoding="UTF-8"?> 

<!-- 
Copyright (c) 2008, 2009 SOPERA GmbH. 
All rights reserved. This program and the accompanying materials 
are made available under the terms of the Eclipse Public License v1.0 
which accompanies this distribution, and is available at 
http://www.eclipse.org/legal/epl-v10.html 

Contributors: 
    SOPERA GmbH - initial API and implementation 
--> 

<spring:beans xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:osgi="http://www.springframework.org/schema/osgi" 
    xmlns:camel-osgi="ht_tp://activemq.apache.org/camel/schema/osgi" 
    xmlns:http="http://servicemix.apache.org/http/1.0" 
    xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd 
    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
    http://servicemix.apache.org/http/1.0 http://servicemix.apache.org/http/1.0/servicemix-http.xsd" 
    xmlns:serviceNamespace="ht_tp://www.IECImpl.org/ServerServerProtocoll/" 
    xmlns="ht-tp://www.IECImpl.org/ServerServerProtocoll/">  

<spring:import resource="classpath:META-INF/cxf/cxf.xml" /> 
<spring:import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
<spring:import resource="classpath:META-INF/org/eclipse/swordfish/plugins/cxf/support/nmr-transport.xml" /> 

<jaxws:client id="ServerServerProtocollClient" 
       serviceClass="org.iecimpl.serverserverprotocoll.ServerServerProtocoll" 
       serviceName="serviceNamespace:ServerServerProtocoll" 
       address="nmr:ServerServerProtocoll" /> 
<spring:bean class="org.iecimpl.serverserverprotocoll.sample.ServerServerProtocollClientInvoker"> 
<spring:property name="serverServerProtocoll" ref="ServerServerProtocollClient"/> 
</spring:bean>  


<spring:bean class="org.apache.servicemix.common.osgi.EndpointExporter" /> 

<http:endpoint endpoint="cxfEndpointHttpProvider"     
      service="serviceNamespace:ServerServerProtocoll" 
      locationURI="http://localhost:1001/EnergyServer" 
      soap="true" 
      role="provider"/> 

toutes les données est définie, mais je suis un newbee dans ce domaine.

+0

Aucune idée? personne? – Muuh

+0

voulez-vous vous connecter manuellement à votre service depuis eclipse IDE? – UVM

+0

Désolé, je n'ai pas vu que vous avez répondu. Je veux me connecter dynamiquement à partir de Javacode sans utiliser Springmetadata. – Muuh

Répondre

1

Je me demande pourquoi vous perdriez la valeur de serverServerProtocoll ??? Du code que vous avez posté, ce n'est pas clair. Si la valeur « soudainement » devient nulle, il doit y avoir une mission qui fait que ...

Vous pouvez essayer cette solution de contournement: Comme Espadon utilise en interne CXF, vous pouvez simplement créer un org.apache.cxf.jaxws.JaxWsProxyFactoryBean dans la configuration de votre ressort de consommation.

Chaque fois que vous avez besoin d'un client pour votre service, vous pouvez en créer un en utilisant le bean-usine défini dans votre contexte d'application Spring.

Voir: Configuring a Spring Client (Option 2)