简单的Web服务:将端点名称,服务名称等放在一起 [英] simple web service: putting endpointname, servicename, etc. together

查看:125
本文介绍了简单的Web服务:将端点名称,服务名称等放在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Apache最简单的 Hello World Web服务(

(来源: javatips.net


在上面的屏幕快照中,您可以看到目标名称空间 http://student.com ,这是因为我们被创建为 com.student 的程序包。
目标名称空间必须与Java包相反,还需要在包之前附加 http://


参考我的博客


http://javatips.net/blog/2012/04/expose-cxf-service-with-rest-and-soap


I'm trying Apache's simplest "Hello World" webservice (http://cxf.apache.org/docs/a-simple-jax-ws-service.html); I have purposely altered it a little to learn more about how to do things instead of just copying all their code.

My service implementation specifies the interface it implements in the package "hw":

@WebService(endpointInterface = "hw.HelloWorld", serviceName = "HelloWorld")

The program that "publishes" the web service (which I gather means operates as the server for it) has the implementation in its own (quite correct) package:

HelloWorldImpl implementor = new hwimpl.HelloworldImpl();
Endpoint.publish("http://localhost:9000/helloworld", implementor);

and then sleeps for 5 minutes, during which time the URL the instructions say to put in the browser displays the WSDL. That much works.

http://localhost:9000/helloWorld?wsdl

My client has:

private static final QName SERVICE_NAME 
    = new QName("http://server.hw.demo/", "HelloWorld");
private static final QName PORT_NAME 
    = new QName("http://server.hw.demo/", "HelloWorldPort");

// the following in a method, of course
String endpointAddress = "http://localhost:9000/helloWorld";
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
HelloWorld hw = service.getPort(HelloWorld.class);
System.out.println(hw.sayHi("Albert"));

I don't know how SERVICE_NAME and PORT_NAME relate to my service. The "server.hw.demo" strings came from the example, and do not correspond to packages in my code, or "reversed" packages as seemed to be used for namespaces; should they? What do they correspond to? I have nothing in my code, except here, that uses "server.hw.demo"; what is that string supposed to be?

Does it matter that my implementation and my interface are in different classes?

My client does not work, and I posted that as a question, but it's long and no one has responded to it. I am making a stab at understanding this part; it seems to me the most likely culprit. I'd delete the other question if I knew how.

解决方案


(source: javatips.net)

Above screenshot you can see that Target namespace http://student.com , this is because we are created package as com.student. Target namespace must be on reverse order of a java package, also need to append http:// before the package

Reference my blog:

http://javatips.net/blog/2012/04/expose-cxf-service-with-rest-and-soap

这篇关于简单的Web服务:将端点名称,服务名称等放在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆