Hi,

I am developing a simple web service interface to an existing web application 
(java-first). I am using Apache CXF  2.2.5 and Spring 2.5.6.

I have defined a simple web service interface:

@WebService
public interface MyServices {
    public @WebResult(name="rental")Rental 
getClaimByReferenceNumber(@WebParam(name="referenceNumber") String 
referenceNumber);
}

and its corresponding implementation:

@WebService(endpointInterface = "my.services.MyServices")
public class MyServicesImpl implements MyServices {
    @Autowired
    private ClaimService claimService;

    public void setClaimService(ClaimService claimService) {
        this.claimService = claimService;
    }

    @Transactional
//    @WebMethod
    @Override
    public Rental getClaimByReferenceNumber(String choReferenceNumber) {

        Claim claim = 
claimService.getClaimByReferenceNumber(choReferenceNumber);

        Rental rental = MapUtils.convert(claim);

        return rental;
    }
...

I can install this web service (on Tomcat 6.0.20) and it seems to work ok.

I then generate a test client to test the web service, using netbeans 6.8 'New 
Web service Client' wizard, pointing the wizard to the WSDL URL.
The following test method correctly calls the web service and marshals the 
result to a file:

public class TestGetClaimService {

    private static final String[] LOCATIONS = {"context.xml"};

    public static void main(String[] args) throws Exception {
        ApplicationContext ctx = new ClassPathXmlApplicationContext(LOCATIONS);

        AXServices client = (AXServices) ctx.getBean("myServices");

        GetClaimByReferenceNumberResponse.Rental rental = 
client.getClaimByReferenceNumber("1923988");
        JAXBContext context = 
JAXBContext.newInstance(GetClaimByReferenceNumberResponse.Rental.class);

        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        System.out.println("Claim is: ");
        m.marshal(rental, System.out);
}


The problem I have is that I now have a 
GetClaimByReferenceNumberResponse.Rental object, whereas what I actually want 
is a Rental object (both classes are automatically generated from the WSDL 
file). How can I achieve this, i.e. return a plain object from the web service 
call rather than having it wrapped-up in a response object,

   Rental rental = client.getClaimByReferenceNumber("1923988");
        JAXBContext context = JAXBContext.newInstance(Rental.class);
...

I am guessing that this is a common problem but have not managed to find a 
solution. All the tutorials I have seen seem to be able to return the business 
object directly (i.e. not wrapped in a response), but I am unsure of how they 
are doing this. I am new to Apache CXF and web services in general, as well as 
this user list, so please forgive me if this question has already been posed 
(how do you search the user lists?).

Let me know if you need anything else (WSDL file, for example)

Thanks in advance,



John L. Dowson MSc
Senior Developer

Tel: +44 (0)1923 883921
Mobile: +44 (0)7929 630850
Email: 
[email protected]<mailto:[email protected]>









________________________________
Sherwood Compliance Services
Batchworth Park, London Road, Rickmansworth, Hertfordshire. WD3 1JS


This e-mail is only intended for the person(s) to whom it is addressed and may 
contain confidential information.

Sherwood Compliance Services does not accept responsibility for any loss or 
damage caused by this e-mail or any attachments. Any opinions or comments may 
be personal to the writer and may not represent the view of Sherwood Compliance 
Services. If you have received this e-mail in error, please notify the sender 
immediately and then delete this message from your system.

Company registered in England 4819089 at 55 Station Road, Beaconsfield, 
Buckinghamshire. HP9 1QS

Reply via email to