简体   繁体   中英

Java-ws tomcat invoke methods through http?

I made a web project in Java, using Java-WS. How can I invoke service methods through HTTP only. I don't want to generate (or worse write) any java web clients, and similar stuff. I'd just like to invoke the method with a HTTP request. And parse the result (manually) from response.

In .NET web services I invoke methods just with:

http://serviceUrl/serviceName.asmx/operationName?parametars=...

How to do the same thing in java + tomcat?

Edit: Let me rephrase my question. So this is what I have done so far:

  • Created a web application (btw. using NetBeans IDE)
  • Added all the necessary source files
  • Added web service classes with WebMethods defined

I deploy the app on tomcat and it deploys fine. Now, what do I need to do to be able to invoke my WebMethods via HTTP?

Typing:

http://localhost:8084/MyService/MyMethod

doesn't work.

Sorry if this is a stupid question, but I'm not really a Java guru, I've been working mostly on .NET.

Multiple possibilities:

  • use new URL(url).openConnection().getInputStream()
  • use apache http components
  • use a REST client (if you invoke restful services), like http://code.google.com/p/rest-client/">this, or these . Or spring's RestTemplate

In this case, if you want to do an HTTP Web Service that returns an HTTP 200 Web Response, why not look at doing a RESTFul application?

JavaWorld briefly explains the role/use of REST. There's been similar questions on REST tutorials in SO . I hope this helps you.

Apache CXF has a 'plain http binding', but we recommend that people write JAX-RS services, instead. They are very, very, simple. However, the plain HTTP binding is there and supports GET.

I generate a RESTful Web Service in NetBeans by clicking on "Generate SOAP-over-HTTP Wrapper" in my service context menu. It generated successfully, compiles and deploys fine. But I still can't figure out how to make a HTTP invoke

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM