Dear all,

I hope you can help me with this problem. Let me describe exactly what I
did.

1) I created 2 projects, a Web Service and a Web Service Client in Eclipse
using CXF, following these video
tutorials<https://www.youtube.com/watch?v=UpZgxutMgYg>
.

Up until here, this works in the Client:

        URL wsdlURL = DeviceProxyService.WSDL_LOCATION;

        DeviceProxyService ss = new DeviceProxyService(wsdlURL,
SERVICE_NAME);
        DeviceProxySEI port = ss.getDeviceProxyPort();

        String result = port.whatIsTheAnswer("42");
        System.out.println("whatIsTheAnswer.result=" + result);

2) I added the 2 jars (cxf-services-ws-discovery-api-2.7.3.jar and
cxf-services-ws-discovery-service-2.7.3.jar) to the Java Build Path
libraries of both projects.

3) I exchanged the previous code for this:

        (1) WSDiscoveryClient client = new WSDiscoveryClient();
        (2) List<EndpointReference> references = client.probe(new QName("
http://ws/";, "DeviceProxySEI"));
        (3) client.close();

        (4) DeviceProxyService service = new DeviceProxyService();

        (5) for (EndpointReference ref : references) {
        (6)    DeviceProxySEI dp = service.getPort(ref,
DeviceProxySEI.class);
        (7)    String s = dp.whatIsTheAnswer("42");
        (8)    System.out.println(s);
        (9) }

4) Now I'm going to tell you what happens when I debug this code in the
relevant lines:

        (2) references= [<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><EndpointReference xmlns="
http://www.w3.org/2005/08/addressing
"><Address>/DeviceProxyPort</Address><ReferenceParameters/></EndpointReference>]

        (6) No errors until here.

        (7) WARNING: Interceptor for {
http://ws/}DeviceProxyService#{http://ws/}whatIsTheAnswer has thrown
exception, unwinding now

             org.apache.cxf.interceptor.Fault: Could not send Message.

             Caused by: java.net.MalformedURLException: unknown protocol:
null

             (See full exception in the attachment Screenshot1.png)


There are some things I don't understand:

a) I get the reference in line (2), but why does it only contain
"/DeviceProxyPort" in the <Address> tag? Shouldn't it contain the whole
WSDL URL? I will not know the WSDL URLs of the services, and that is why I
want to use WS-Discovery to discover them (See Screenshot2.png for the
content of "references" during debug).

b) In line (4) "new DeviceProxyService()". This constructor was generated
by Eclipse and has the Web Service WSDL URL hardcoded inside, which that
class needs to create the Service. I will not know the WSDL URL, so I
though of removing the hardcoded one from inside that class. But I have
nothing to give it instead, since I don't get the WSDL URL from the
references in line (2) currently.

c) Then again, I don't know if it doesn't matter at all what WSDL URL the
"new DeviceProxyService()" uses, because for now I'm letting it use the
hardcoded one, which is the right WSDL URL. And yet, it's throwing the
exception in line (7). So, even if the Service is created with the right
WSDL URL (which is hardcoded now, but could be coming in the references as
well), the exception is thrown in line (7).


I think the problem is in the result of line (2) when getting the
references, because when the reference is used to get the port in line (6),
it gets something as a port, but then it's not useful when you want to call
the method "whatIsTheAnswer" from it in line (7).

Since this all happens automatically, I don't know what I can do to fix the
problem. I really hope you can help me, since I'm working on a time crunch.

Looking forward to your reply.

Best regards,
Beatriz Avila.

Reply via email to