Hi,

I have a problem with Cxf 2.1.2. When I send a SOAP message which is
declared as document/litteral in the WSDL document, the body of this one is
always wrapped with the tag name of the wsdl:operation even if the following
method JaxWsServiceFactoryBean.setWrapped(false) is set to false.

Is it a bug ?

1) Here is my client code :

Here is the CXF code that I use :

package com.xpectis.service.tracker;

import java.util.GregorianCalendar;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Test;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import junit.framework.Assert;

public class TrackerServiceTest {
       
        private static String ADDRESS = "http://localhost:9000/tracker";;
       
        //TrackerService trackerService;
       
           /** The Constant LOG. */
    private static final Log LOG =
LogFactory.getLog(TrackerServiceTest.class);

     /**
     * Test call PostParcel Web Service.
     *
     * @throws Exception the exception
     */
        @Test
    public void testPostParcel() throws Exception
    {
               
                // Create Client Proxy
                ClientProxyFactoryBean factory = new
JaxWsProxyFactoryBean();
                JaxWsServiceFactoryBean sf = new JaxWsServiceFactoryBean();
                sf.setWrapped(false);
                factory.setServiceFactory(sf);
                factory.setServiceClass(TrackParcelEndpoint.class);
                factory.setAddress(ADDRESS);
                factory.getInInterceptors().add(new LoggingInInterceptor());
                factory.getOutInterceptors().add(new
LoggingOutInterceptor());

                TrackParcelEndpoint client = (TrackParcelEndpoint)
factory.create();
               
                // Create InputTrackParcel client
                InputTrackParcel parcel = new InputTrackParcel();
                parcel.setName("chm");
                parcel.setDestination("Brussels");
                parcel.setOrigin("Florennes");
                //parcel.setDeliveryDate(calendar);
               
                // Call web service
                OutputTrackParcel result = client.PostParcel(parcel);
                LOG.info("Result : " + result.getReference());
                Assert.assertNotNull(result);
               
               
    }
   
}

2) WSDL file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
  targetNamespace="http://tracker.service.xpectis.com";
  xmlns="http://schemas.xmlsoap.org/wsdl/"; 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
  xmlns:tns="http://tracker.service.xpectis.com";
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  
  <!-- Type definitions for input- and output parameters for webservice -->
  <wsdl:types>
    <xsd:schema targetNamespace="http://tracker.service.xpectis.com";>
      <xsd:element name="inputTrackParcel">
        <xsd:complexType>
          <xsd:sequence>
                <xsd:element name="name" type="xsd:string" maxOccurs="1"
minOccurs="1"/>
                <xsd:element name="destination" type="xsd:string" maxOccurs="1"
minOccurs="1"></xsd:element>
                <xsd:element name="origin" type="xsd:string"></xsd:element>
                <xsd:element name="deliveryDate" type="xsd:date" maxOccurs="1"
minOccurs="0"></xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="outputTrackParcel">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="reference" type="xsd:int"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  
  <!-- Message definitions for input and output -->  
  <wsdl:message name="inputTrackParcel">
    <wsdl:part element="tns:inputTrackParcel" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="outputTrackParcel">
    <wsdl:part element="tns:outputTrackParcel" name="parameters"/>
  </wsdl:message>
  
  <!-- Port (interface) definitions -->
  <wsdl:portType name="TrackParcelEndpoint">
    <wsdl:operation name="PostParcel">
      <wsdl:input message="tns:inputTrackParcel"/>
      <wsdl:output message="tns:outputTrackParcel"/>
    </wsdl:operation>
  </wsdl:portType>
  
  <!-- Port bindings to transports and encoding - HTTP, document literal
encoding is used -->  
  <wsdl:binding name="TrackParcelBinding" type="tns:TrackParcelEndpoint">
    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="PostParcel">
      <soap:operation
soapAction="http://tracker.service.xpectis.com/PostParcel"/>
      <wsdl:input>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <!-- Service definition -->
  <wsdl:service name="TrackParcelService">
    <wsdl:port binding="tns:TrackParcelBinding" name="TrackParcelPort">
      <soap:address location="http://tracker.service.xpectis.com"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

3) Message generated whe we can see that PostParcel operation tag has been
add (<ns1:PostParcel xmlns:ns1="http://tracker.service.xpectis.com/";>)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
<soap:Body>
<ns1:PostParcel xmlns:ns1="http://tracker.service.xpectis.com/";>
<ns2:inputTrackParcel xmlns:ns2="http://tracker.service.xpectis.com";>
<name>chm</name>
<destination>Brussels</destination>
<origin>Florennes</origin>
</ns2:inputTrackParcel>
</ns1:PostParcel>
</soap:Body>
</soap:Envelope>

Charles Moulliard



-----
Enterprise Architect

Xpectis
12, route d'Esch
L-1470 Luxembourg

Phone +352 25 10 70 470
Mobile +352 621 45 36 22

e-mail : [EMAIL PROTECTED]
web site :  www.xpectis.com www.xpectis.com 
My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/SOAP-message-WRAPPED-even-if-JaxWsServiceFactoryBean.setWrapped%28false%29.-Is-it-a-bug----tp19896311p19896311.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to