JBoss Community

Consume a web service from another web service

created by florentine in JBoss Web Services Development - View the full discussion

Hi all,

I'm new to the web service world so I apologize for my naive question.

 

I created a very basic web service that I am able to successfully call from a web client. What I want to do now is to create a second web service that uses the service exposed by the first one to provide its own functionality.

 

These are my classes/web services:

 

HelloWorld.java (External Web Service)

{code}

package hw1;

 

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.soap.SOAPBinding;

import javax.jws.soap.SOAPBinding.Style;

 

@WebService

@SOAPBinding(style = Style.RPC)

public interface HelloWorld {

 

    @WebMethod String getHiWorld();

}

{code}

 

HelloWorldImpl.java

{code}

package hw1;

 

import hw2.HelloWorld2;

 

 

import javax.jws.WebMethod;

import javax.jws.WebService;

import javax.xml.ws.WebServiceRef;

 

@WebService(serviceName = "HelloWorldService", name = "HelloWorld")

public class HelloWorldImpl implements HelloWorld {

 

    @WebServiceRef(type = HelloWorld2.class)

    private HelloWorld2Service service;

 

    @Override

    @WebMethod

    public String getHiWorld() {

        HelloWorld2 port = service.getHelloWorld2Port();

        return "Hi World" + port.getHiWorld();

 

    }

 

}

{code}

 

 

HelloWorld2.java (Internal Web Service)


{code}

package hw2;

 

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.soap.SOAPBinding;

 

 

@WebService

@SOAPBinding(style=SOAPBinding.Style.RPC)

public interface HelloWorld2 {

 

    @WebMethod String getHiWorld();

}

{code}

 

HelloWorld2Impl.java

{code}

package hw2;

 

import javax.jws.WebMethod;

import javax.jws.WebService;

 

 

 

@WebService(serviceName="HelloWorld2Service", name="HelloWorld2")   

public class HelloWorld2Impl implements HelloWorld2 {

 

 

    @Override

    @WebMethod

    public String getHiWorld() {

            return " again!";

       

 

    }

   

public HelloWorld2Impl (){}

}

{code}

 

 

The error I get is that in HelloWorld.java, the HelloWorld2Service cannot be resolved to a type.

I am developing with Eclipse Indigo, I'm using JBOSS 7 AS, and I have the Java 1.7 installed on my pc.

 

Thanks in advance for any help or hint you can provide.

 

Filippo

Reply to this message by going to Community

Start a new discussion in JBoss Web Services Development at Community