Ceki,

To use Ws-Addressing you need to force the load of an
AddressingOperationInfo object. The following code will do this for
you:

/**
* @author xpbo
*
* This class registers an AddressingOperationInfo object with an
* OperationInfo, as required to support WS-Addressing.
*/
public class MyServiceFactory extends JAXWSServiceFactory {
        
        /**
         * Forces a new AddressingOperationInfo object to be registered with the
         * OperationInfo.
         */
        @Override
        protected OperationInfo addOperation(
                        Service endpoint, Method method, String style)
   {
                OperationInfo op = super.addOperation(endpoint, method, style);
                /*
                 * The AddressingOperationInfo ctor registers itself so nothing 
need
                 * be done with the new object in this method.
                 *
                 * The "Response" string is appended to the action to provide a
                 * return string that matches that expected by the C# client.
                 */
                String action = getAction(op);
       new AddressingOperationInfo(action, action + "Response", null, op);

       return op;
   }
}


Be sure then to register this class in your config.


Phil

On 15/03/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Hello,

I would like to publish a web-service using XFire+JSR181
Annotations+WS-Addressing. After spending several hours without much
success, knocking at the door of this list may be in order.

I am configuring XFire programmatically using my own servlet as shown
below. By the way, I can get the service working without WS-Addressing
just fine.

Without further ado, here is my servlet.

// ----------------------------------------------------------
package ch.qos.arte;

import javax.servlet.ServletException;
import javax.xml.namespace.QName;
import org.codehaus.xfire.DefaultXFire;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.addressing.AddressingInHandler;
import org.codehaus.xfire.addressing.AddressingOutHandler;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.server.http.XFireHttpServer;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.transport.http.XFireServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyXfireServlet extends XFireServlet {

  private static final long serialVersionUID = 14536657L;
  Logger logger = LoggerFactory.getLogger(MyXfireServlet.class);

  public XFire createXFire() throws ServletException {
    logger.debug("createXFire() called");

    try {
      XFire xfire = (XFire) getServletContext().getAttribute(XFIRE_INSTANCE);
      if (xfire == null) {
        XFireFactory factory = XFireFactory.newInstance();
        xfire = factory.getXFire();
        ((DefaultXFire) xfire).addInHandler(new AddressingInHandler());
        ((DefaultXFire) xfire).addOutHandler(new AddressingOutHandler());

        Service echoService = registerServiceAnnotation(xfire, new 
EchoServiceImpl(),
            new QName("http://www.qos.ch/arte";, "EchoService"));
        xfire.getServiceRegistry().register(echoService);

        getServletContext().setAttribute(XFIRE_INSTANCE, xfire);
      }
      return xfire;
    } catch (Exception e) {
      logger.error("Couldn't start XFire", e);
      throw new ServletException("Couldn't start XFire.", e);
    }
  }

  Service registerServiceAnnotation(XFire xfire, Object serviceImpl, QName 
qname) {
    AnnotationServiceFactory factory = new 
AnnotationServiceFactory(xfire.getTransportManager());
    Service service = factory.create(serviceImpl.getClass());
    service.setName(qname);
    return service;
  }
}


Here is the interface I wish to expose:

// ----------------------------------------------------------
package ch.qos.arte;

import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;

@WebService(name = "EchoService", targetNamespace = "http://www.qos.ch/arte";)
public interface EchoService {

  @WebMethod(operationName = "doEcho", action = "urn:doEcho")
  @WebResult(name = "echoResult")
  public String doEcho(String in);
}
// ----------------------------------------------------------

The implementation:

// ----------------------------------------------------------
package ch.qos.arte.xfire;
import javax.jws.WebService;

@WebService(endpointInterface = "ch.qos.arte.EchoService", 
serviceName="EchoService")
public class EchoServiceImpl implements EchoService {

  public EchoServiceImpl() {
  }


  public String doEcho(String in) {
    return "You said: "+ in;
  }
}
// ---------------------------------------------------------------------------


Using soapUI, I forward the following SOAP request:

// --------------------------------------------------------------------------
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:a="http://www.w3.org/2005/08/addressing";>
    <s:Header>
        <a:Action s:mustUnderstand="1">urn:doEcho</a:Action>
        <a:To>http://www.qos.ch/arte/EchoService</a:To>
        <a:MessageID>urn:uuid:c87f9f62-79bb-4f93-bfd8-aaac26856cbf</a:MessageID>
     </s:Header>
     <s:Body>
            <doEcho xmlns="http://www.qos.ch/arte";>
                 <inputStr>sd</inputStr>
              </doEcho>
      </s:Body>
</s:Envelope>
// ------------------------------------------------------------------------

Here is the response:

// ------------------------------------------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
               xmlns:xsd="http://www.w3.org/2001/XMLSchema";
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Action 'urn:doEcho' was not found for service 
http://www.qos.ch/arte/EchoService</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
// ------------------------------------------------------------------------


Going through the code with a debugger, I can see that on line 89 in
the invoke method(MessageContext) method
of o.c.xfire.addressing.AddressingInHandler class (see below), the
context.getExchange().getOperation() returns null.


 88: // Dispatch the Exchange and operation
 89: OperationInfo op = context.getExchange().getOperation();
 90: AddressingOperationInfo aop = 
AddressingOperationInfo.getOperationByInAction(service.getServiceInfo(), headers


Any suggestions to put me on the right track?

Many thanks in advance,

************************ DISCLAIMER ************************
This message is intended only for use by the person
to whom it is addressed. It may contain information
that is privileged and confidential. Its content does
not constitute a formal commitment by Lombard
Odier Darier Hentsch Group and any of its affiliates.
If you are not the intended recipient of this message,
kindly notify the sender immediately and destroy this
message. Thank You.
*****************************************************************


---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to