You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Andrew Clegg <an...@gmail.com> on 2008/10/28 23:15:39 UTC

Re: New CXF User question: Need a replacement for a PHP web service

I'm not entirely sure what you want to do -- are you after a SOAP or
REST service?

If SOAP, then there's a good tutorial here which covers Tomcat:

http://www.jroller.com/gmazza/date/20080417

I'm only a noob myself, but this is what got me started, and I still
refer back to it fairly often. Ignore the bits about Glassfish Metro,
and I found after starting with the Ant-based instructions that in the
end the Maven-based route worked more smoothly.

This tutorial covers specifying a WSDL first, then auto-generating the
Java classes from that, rather than the other way round. This is
probably what you want to do if you're designing a service to meet an
existing spec. Otherwise you'll end up tweaking bits of Java here and
there in the hope that the WSDL that comes out matches what your
existing clients expect -- and that'll just lead to tears. If you
really want to do Java-first there are other tutorials out there that
Google will lead you to.

If you're testing SOAP services, you absolutely want to get soapUI
(soapui.org), trying to do it manually with wget will just be painful.

If on the other hand you're after a REST service, then I'm afraid I
can't help you much, as I've never done that :-)

But {cxf rest tutorial} gets quite a few Google hits.

Good luck!

Andrew.

2008/10/28 Joseph Fair <JF...@envysion.com>:
> Group,
>
>
>
> I've been banging my head for two days on a replacement for a PHP web
> service.  The current service posts data from a Java web server and the
> PHP takes the string, parses the xml, builds the xml response, and sends
> it back.  I'm trying to do it with the (highly recommended) CXF library,
> Java 1.5, and tomcat.  I have looked at the users guide, but I kept
> getting tripped up on the fact that I'm using Tomcat and the examples
> are not for tomcat.
>
>
>
> Instead, I implemented a service using this tutorial
>
> http://www.benmccann.com/dev-blog/web-services-tutorial-with-apache-cxf/
>
>
>
> only to realize that now (think) I've got a soap-based web service, not
> a RESTful one.
>
>
>
> I have a couple questions:
>
> 1.  What is the best way to do this replacement?  If there is a good,
> simple example that includes setting it up for tomcat I'd appreciate it.
>
>
>
> 2.       When I post to the web service
>
>
>
> wget  --post-data="<searchQuery
> xmlns='http://xml.envysion.com'>copl</searchQuery>"
> --no-check-certificate
> http://localhost/video-copy-agent/services/VideoCopyServiceAddress/copyR
> equest
>
>
>
> I get back
>
> ERROR 500: Internal Server Error.
>
> And the logs say
>
> org.apache.cxf.binding.soap.SoapFault: "http://xml.envysion.com", the
> namespace on the "searchQuery" element, is not a valid SOAP version.
>
>
>
>
>
> I can change the request to include a name space, but can't I get around
> it? I don't really need it.
>
>
>
>
>
>
>
> 3.  Does this look like the right idea:
>
>
>
> csf.xml :
>
> ...
>
>  <jaxws:endpoint id="videoCopyService"
>
>
> implementor="com.envysion.nakika.videocopy.service.impl.VideoCopyAgentSe
> rviceImpl"
>
>                  address="/VideoCopyServiceAddress"/>
>
> ...
>
>
>
>
>
> VideoCopyAgentServiceImpl.java
>
> ...
>
> @WebService(endpointInterface =
> "com.envysion.nakika.videocopy.service.VideoCopyAgentService",
> serviceName = "publicVideoCopyAgentService")
>
> public class VideoCopyAgentServiceImpl
>
>  implements VideoCopyAgentService
>
> {
>
> ...
>
>  public String copyRequest(String searchQuery)
>
>  {
>
>  }
>
> }
>
>
>
>
>
> VideoCopyAgentService.java
>
> ...
>
> @WebService(targetNamespace = "http://xml.envysion.com")
>
> public interface VideoCopyAgentService
>
> {
>
> ...
>
> public String copyRequest(@WebParam(name="searchQuery") String
> searchQuery);
>
> }
>
>
>
>
>
>

Re: New CXF User question: Need a replacement for a PHP web service

Posted by Sergey Beryozkin <se...@progress.com>.
Hi Gabo

Thanks for this info, the only clarification is that 0.8 is now supported in 2.1.x branch (2.1.3), with the possibility of it 
supporting 1.0 at a later stage, while 2.2-SNAPSHOT now supports 1.0-final (with few exceptions)

Cheers, Sergey

> Hi Joseph,
>
>> I have looked at the users guide, but I kept getting tripped up on the fact that I'm using Tomcat and the examples are not for 
>> tomcat.
>
>
> If you are going to use java, tomcat and cxf for a ReST service. Then I suggest reading up on the user's guide. 
> (http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html). jsr311-api-0.8.jar contains all the annotations mentioned in that page. I 
> followed this page and am able to have a ReST service in a day or two. For simple services, the following headers should suffice:
>
> Resource class
> @Path
> HTTP Method
> Dealing with Parameters
> Sub-resource locators.
> Configuring JAX-RS services in container with Spring configuration file. **
>
> From the samples folder of the downloaded jar, its only difference is that the service instances are configured/started 
> programatically. The section above which i marked with ** should help have the same service deployed in tomcat.
>
> To set-up the said services in tomcat, just create a folder in webapps. have WEB-INF in that folder, and lib in the WEB-INF 
> folder. Have the web.xml and beans.xml in the WEB-INF directory; and the needed jars in the lib including your service.
>
> Hth.
>
> Gabo
>
> Benson Margulies wrote:
>> Why don't you start by getting to the point where you have a .war file
>> for a REST-ful service, based on the samples, that works in jetty?
>> Then drop that into Tomcat and tell us what doesn't work.
>>
>> On Tue, Oct 28, 2008 at 7:21 PM, Joseph Fair <JF...@envysion.com> wrote:
>>
>>> Thanks.  I have looked at that, but it raises some questions:
>>> 1.  Where do I put the @WebService annotations?  I started in the
>>> interface, but this has them on the implementation, too.
>>> 2.  This sets a "targetNameSpace" attribute in the annotation for the
>>> interface
>>> @WebService(targetNamespace = "http://customer.acme.com")
>>> public interface CustomerService {
>>>
>>> I tried that, too, but with no visible difference.
>>>
>>>
>>> -----Original Message-----
>>> From: Andrew Clegg [mailto:andrew.clegg@gmail.com]
>>> Sent: Tuesday, October 28, 2008 4:43 PM
>>> To: users@cxf.apache.org
>>> Subject: Re: New CXF User question: Need a replacement for a PHP web
>>> service
>>>
>>> I can't be much help then I'm afraid, although there's plenty of
>>> others here who know much more about REST.
>>>
>>> In the meantime though, maybe this would help?
>>>
>>> http://www.java2s.com/Code/Java/Web-Services-SOA/Thisdemoshowshowtocreat
>>> eRESTfulservicesusingCXFsHTTPbinding.htm
>>>
>>> Andrew.
>>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.8.4/1753 - Release Date: 10/28/2008 9:20 PM
>>
>> 


Re: New CXF User question: Need a replacement for a PHP web service

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Joseph,

> I have looked at the users guide, but I kept getting tripped up on the fact that I'm using Tomcat and the examples are not for tomcat.


If you are going to use java, tomcat and cxf for a ReST service. Then I 
suggest reading up on the user's guide. 
(http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html). 
jsr311-api-0.8.jar contains all the annotations mentioned in that page. 
I followed this page and am able to have a ReST service in a day or two. 
For simple services, the following headers should suffice:

Resource class
@Path
HTTP Method
Dealing with Parameters
Sub-resource locators.
Configuring JAX-RS services in container with Spring configuration file. **

 From the samples folder of the downloaded jar, its only difference is 
that the service instances are configured/started programatically. The 
section above which i marked with ** should help have the same service 
deployed in tomcat.

To set-up the said services in tomcat, just create a folder in webapps. 
have WEB-INF in that folder, and lib in the WEB-INF folder. Have the 
web.xml and beans.xml in the WEB-INF directory; and the needed jars in 
the lib including your service.

Hth.

Gabo

Benson Margulies wrote:
> Why don't you start by getting to the point where you have a .war file
> for a REST-ful service, based on the samples, that works in jetty?
> Then drop that into Tomcat and tell us what doesn't work.
>
> On Tue, Oct 28, 2008 at 7:21 PM, Joseph Fair <JF...@envysion.com> wrote:
>   
>> Thanks.  I have looked at that, but it raises some questions:
>> 1.  Where do I put the @WebService annotations?  I started in the
>> interface, but this has them on the implementation, too.
>> 2.  This sets a "targetNameSpace" attribute in the annotation for the
>> interface
>> @WebService(targetNamespace = "http://customer.acme.com")
>> public interface CustomerService {
>>
>> I tried that, too, but with no visible difference.
>>
>>
>> -----Original Message-----
>> From: Andrew Clegg [mailto:andrew.clegg@gmail.com]
>> Sent: Tuesday, October 28, 2008 4:43 PM
>> To: users@cxf.apache.org
>> Subject: Re: New CXF User question: Need a replacement for a PHP web
>> service
>>
>> I can't be much help then I'm afraid, although there's plenty of
>> others here who know much more about REST.
>>
>> In the meantime though, maybe this would help?
>>
>> http://www.java2s.com/Code/Java/Web-Services-SOA/Thisdemoshowshowtocreat
>> eRESTfulservicesusingCXFsHTTPbinding.htm
>>
>> Andrew.
>>     
> >
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.175 / Virus Database: 270.8.4/1753 - Release Date: 10/28/2008 9:20 PM
>
>   

Re: New CXF User question: Need a replacement for a PHP web service

Posted by Benson Margulies <bi...@gmail.com>.
Why don't you start by getting to the point where you have a .war file
for a REST-ful service, based on the samples, that works in jetty?
Then drop that into Tomcat and tell us what doesn't work.

On Tue, Oct 28, 2008 at 7:21 PM, Joseph Fair <JF...@envysion.com> wrote:
> Thanks.  I have looked at that, but it raises some questions:
> 1.  Where do I put the @WebService annotations?  I started in the
> interface, but this has them on the implementation, too.
> 2.  This sets a "targetNameSpace" attribute in the annotation for the
> interface
> @WebService(targetNamespace = "http://customer.acme.com")
> public interface CustomerService {
>
> I tried that, too, but with no visible difference.
>
>
> -----Original Message-----
> From: Andrew Clegg [mailto:andrew.clegg@gmail.com]
> Sent: Tuesday, October 28, 2008 4:43 PM
> To: users@cxf.apache.org
> Subject: Re: New CXF User question: Need a replacement for a PHP web
> service
>
> I can't be much help then I'm afraid, although there's plenty of
> others here who know much more about REST.
>
> In the meantime though, maybe this would help?
>
> http://www.java2s.com/Code/Java/Web-Services-SOA/Thisdemoshowshowtocreat
> eRESTfulservicesusingCXFsHTTPbinding.htm
>
> Andrew.
>

RE: New CXF User question: Need a replacement for a PHP web service

Posted by Joseph Fair <JF...@envysion.com>.
Thanks.  I have looked at that, but it raises some questions:
1.  Where do I put the @WebService annotations?  I started in the
interface, but this has them on the implementation, too.
2.  This sets a "targetNameSpace" attribute in the annotation for the
interface
@WebService(targetNamespace = "http://customer.acme.com")
public interface CustomerService {

I tried that, too, but with no visible difference.


-----Original Message-----
From: Andrew Clegg [mailto:andrew.clegg@gmail.com] 
Sent: Tuesday, October 28, 2008 4:43 PM
To: users@cxf.apache.org
Subject: Re: New CXF User question: Need a replacement for a PHP web
service

I can't be much help then I'm afraid, although there's plenty of
others here who know much more about REST.

In the meantime though, maybe this would help?

http://www.java2s.com/Code/Java/Web-Services-SOA/Thisdemoshowshowtocreat
eRESTfulservicesusingCXFsHTTPbinding.htm

Andrew.

Re: New CXF User question: Need a replacement for a PHP web service

Posted by Andrew Clegg <an...@gmail.com>.
I can't be much help then I'm afraid, although there's plenty of
others here who know much more about REST.

In the meantime though, maybe this would help?

http://www.java2s.com/Code/Java/Web-Services-SOA/ThisdemoshowshowtocreateRESTfulservicesusingCXFsHTTPbinding.htm

Andrew.

2008/10/28 Joseph Fair <JF...@envysion.com>:
> Sorry to be unclear.  I'm trying to set up a REST service.  Since the
> original is just very simple, I'd like to keep the message format
> similar.
>
> I went back and tried another third time and realized that I was
> probably creating a soap service the third time.  Armed with that
> knowledge I went back and tried the user guide again.
>
> I got a simple Get method to work.  However, the response still looks
> SOAPy.
> <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><sayHi
> Response xmlns="http://service.videocopy.nakika.envysion.com/"><return>a
> HA!</return></sayHiResponse></soap:Body></soap:Envelope>
>
> The web page that fronts these services makes it look like there is a
> namespace involved that is the implementation package name.
>
> Target namespace: http://impl.service.videocopy.nakika.envysion.com/
>
> But cxf still does not recognize the name space.
>
> wget --post-data="<mess
> xmlns='http://impl.service.videocopy.nakika.envysion.com/'
>>asdfasdfasdf</mess>"
> http://localhost/video-copy-agent/services/DummyServiceAddress/getEcho
> -O -
>
> Oct 28, 2008 4:33:18 PM org.apache.cxf.phase.PhaseInterceptorChain
> doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.binding.soap.SoapFault:
> "http://impl.service.videocopy.nakika.envysion.com/", the namespace on
> the "mess" element, is not a valid SOAP version.
>        at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMes
> sage(ReadHeadersInterceptor.java:94)
>
>
> So my question now is:
>
> What can I use for a valid soap version?
>
> Joe
>
>
> -----Original Message-----
> From: Andrew Clegg [mailto:andrew.clegg@gmail.com]
> Sent: Tuesday, October 28, 2008 4:16 PM
> To: users@cxf.apache.org
> Subject: Re: New CXF User question: Need a replacement for a PHP web
> service
>
> I'm not entirely sure what you want to do -- are you after a SOAP or
> REST service?
>
>

RE: New CXF User question: Need a replacement for a PHP web service

Posted by Joseph Fair <JF...@envysion.com>.
Sorry to be unclear.  I'm trying to set up a REST service.  Since the
original is just very simple, I'd like to keep the message format
similar.

I went back and tried another third time and realized that I was
probably creating a soap service the third time.  Armed with that
knowledge I went back and tried the user guide again.

I got a simple Get method to work.  However, the response still looks
SOAPy.
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><sayHi
Response xmlns="http://service.videocopy.nakika.envysion.com/"><return>a
HA!</return></sayHiResponse></soap:Body></soap:Envelope>

The web page that fronts these services makes it look like there is a
namespace involved that is the implementation package name.

Target namespace: http://impl.service.videocopy.nakika.envysion.com/

But cxf still does not recognize the name space.

wget --post-data="<mess
xmlns='http://impl.service.videocopy.nakika.envysion.com/'
>asdfasdfasdf</mess>"
http://localhost/video-copy-agent/services/DummyServiceAddress/getEcho
-O -

Oct 28, 2008 4:33:18 PM org.apache.cxf.phase.PhaseInterceptorChain
doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault:
"http://impl.service.videocopy.nakika.envysion.com/", the namespace on
the "mess" element, is not a valid SOAP version.
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMes
sage(ReadHeadersInterceptor.java:94)


So my question now is:

What can I use for a valid soap version?

Joe


-----Original Message-----
From: Andrew Clegg [mailto:andrew.clegg@gmail.com] 
Sent: Tuesday, October 28, 2008 4:16 PM
To: users@cxf.apache.org
Subject: Re: New CXF User question: Need a replacement for a PHP web
service

I'm not entirely sure what you want to do -- are you after a SOAP or
REST service?