<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Consume a web service from another web service
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/florentine">florentine</a> in <i>JBoss Web Services Development</i> - <a href="https://community.jboss.org/message/724513#724513">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi all,</p><p>I'm new to the web service world so I apologize for my naive question. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>These are my classes/web services:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>HelloWorld.java (External Web Service)</strong></p><p>{code}</p><p>package hw1;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jws.WebService;</p><p>import javax.jws.WebMethod;</p><p>import javax.jws.soap.SOAPBinding;</p><p>import javax.jws.soap.SOAPBinding.Style;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService</p><p>@SOAPBinding(style = Style.RPC)</p><p>public interface HelloWorld {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @WebMethod String getHiWorld();</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>HelloWorldImpl.java </strong></p><p>{code}</p><p>package hw1;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import hw2.HelloWorld2;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jws.WebMethod;</p><p>import javax.jws.WebService;</p><p>import javax.xml.ws.WebServiceRef;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService(serviceName = "HelloWorldService", name = "HelloWorld")</p><p>public class HelloWorldImpl implements HelloWorld {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @WebServiceRef(type = HelloWorld2.class)</p><p><span style="color: #ff0000;">&#160;&#160;&#160; private HelloWorld2Service service;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160; @WebMethod</p><p>&#160;&#160;&#160; public String getHiWorld() {</p><p><span style="color: #ff0000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; HelloWorld2 port = service.getHelloWorld2Port();</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return "Hi World" + port.getHiWorld();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>HelloWorld2.java (Internal Web Service)</strong></p><p><br/>{code}</p><p>package hw2;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jws.WebService;</p><p>import javax.jws.WebMethod;</p><p>import javax.jws.soap.SOAPBinding;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService</p><p>@SOAPBinding(style=SOAPBinding.Style.RPC)</p><p>public interface HelloWorld2 {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @WebMethod String getHiWorld();</p><p>} </p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>HelloWorld2Impl.java </strong></p><p>{code}</p><p>package hw2;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jws.WebMethod;</p><p>import javax.jws.WebService;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService(serviceName="HelloWorld2Service", name="HelloWorld2")&#160;&#160;&#160; </p><p>public class HelloWorld2Impl implements HelloWorld2 {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160; @WebMethod</p><p>&#160;&#160;&#160; public String getHiWorld() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return " again!";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p>&#160;&#160;&#160; </p><p>public HelloWorld2Impl (){}</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The error I get is that in HelloWorld.java, the HelloWorld2Service cannot be resolved to a type. </p><p>I am developing with Eclipse Indigo, I'm using JBOSS 7 AS, and I have the Java 1.7 installed on my pc.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks in advance for any help or hint you can provide.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Filippo</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/724513#724513">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2047">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>