开发者

SOAP communication without Tomcat or Axis

Hello first of all sorry for my poor english.

I develop with Eclipse. As target platform I use swordfish default. I want to use SOAP as protocol but without an exta kit like Tomcat. I have writte paar of WSDL files. With Swordfish I've build an Provider and an Consumer. It works great for first. But after some time past, the protocollinterface is null, because the session is not valid. Swordfish make all connection full automatical, and I had not found how I cam connect to my Interface manually. (Swordfish using OSGI) How can I retry a connection manually?

here is some code that will be usefull

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....");
 }
}

xml file:

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"/>

all data is defined, but I'm a newbee in this area.


I wonder why you would "loose" the value of serverServerProtocoll ??? From the code you posted, that is not clear. If the value "suddenly" gets null, there must be an assignment that does that...

You could try this workaround: As Swordfish internally uses CXF, you could simply create a org.apache.cxf.jaxws.JaxWsProxyFactoryBean inside your consumer spring configuration.

Whenever you need a client for your service, you could create one using the factory bean defined in your Spring application context.

See: Configuring a Spring Client (Option 2)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜