<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FWeb_Services_SOA%2FREST</id>
		<title>Java/Web Services SOA/REST - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FWeb_Services_SOA%2FREST"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;action=history"/>
		<updated>2026-04-18T19:35:19Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9197&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9197&amp;oldid=prev"/>
				<updated>2010-06-01T07:27:31Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:27, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9196&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9196&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Axis2 client API has facilities to invoke REST interfaces ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample for Yahoo - Search - REST&lt;br /&gt;
=================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
Axis2 client API has facilities to invoke REST interfaces. The API to be used is almost the same&lt;br /&gt;
as the one we use while invoking with REST.&lt;br /&gt;
Yahoo provides a REST API to call its search service. This sample demonstrates how to call Yahoo&lt;br /&gt;
search service using an Axis2 client.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Running The Sample&lt;br /&gt;
==================&lt;br /&gt;
Type &amp;quot;ant&amp;quot; from Axis2_HOME/samples/yahoorestsearch directory.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REST based Web Services using the HTTP binding and JAX-WS Provider/Dispatch ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RESTful Hello World Demo &lt;br /&gt;
========================&lt;br /&gt;
The demo shows REST based Web Services using the HTTP binding and &lt;br /&gt;
JAX-WS Provider/Dispatch. The REST server provides the following services: &lt;br /&gt;
A RESTful customer service is provided on URL http://localhost:9000/customerservice/customer. &lt;br /&gt;
Users access this URI to query or update customer info.&lt;br /&gt;
A HTTP GET request to URL http://localhost:9000/customerservice/customer returns &lt;br /&gt;
a list of customer hyperlinks. This allows client navigates through the &lt;br /&gt;
application states. The XML document returned:&lt;br /&gt;
&amp;lt;Customers&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1234&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1235&amp;quot;&amp;gt; &lt;br /&gt;
      &amp;lt;id&amp;gt;1235&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1236&amp;quot;&amp;gt; &lt;br /&gt;
      &amp;lt;id&amp;gt;1236&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
&amp;lt;/Customers&amp;gt;&lt;br /&gt;
A HTTP GET request to URL http://localhost:9000/customerservice/customer?id=1234 &lt;br /&gt;
returns a customer instance whose id is 1234. The XML document returned:&lt;br /&gt;
&amp;lt;Customer&amp;gt;&lt;br /&gt;
  &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;John&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;phoneNumber&amp;gt;123456&amp;lt;/phoneNumber&amp;gt;&lt;br /&gt;
&amp;lt;/Customer&amp;gt;&lt;br /&gt;
A HTTP POST request to URL http://localhost:9000/customerservice/customer &lt;br /&gt;
with the data:&lt;br /&gt;
&amp;lt;Customer&amp;gt;&lt;br /&gt;
  &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;John&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;phoneNumber&amp;gt;123456&amp;lt;/phoneNumber&amp;gt;&lt;br /&gt;
&amp;lt;/Customer&amp;gt;&lt;br /&gt;
updates customer 1234 with the data provided. &lt;br /&gt;
The client code demonstrates how to send HTTP POST with XML data using &lt;br /&gt;
JAX-WS Dispatch and how to send HTTP GET using URL.openStream(). The &lt;br /&gt;
server code demonstrates how to build a RESTful endpoints through &lt;br /&gt;
JAX-WS Provider interface.&lt;br /&gt;
&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/restful directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/restful directory, first create the target&lt;br /&gt;
directory build/classes and then compile the provided client &lt;br /&gt;
and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/restful/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/restful/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\restful\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\restful\server\*.java&lt;br /&gt;
&lt;br /&gt;
Finally, copy resource files into the build/classes directory with the commands:&lt;br /&gt;
For UNIX:    &lt;br /&gt;
  cp ./src/demo/restful/client/*.xml ./build/classes/demo/restful/client&lt;br /&gt;
  cp ./src/demo/restful/server/*.xml ./build/classes/demo/restful/server&lt;br /&gt;
For Windows:&lt;br /&gt;
  copy src\demo\restful\client\*.xml build\classes\demo\restful\client&lt;br /&gt;
  copy src\demo\restful\server\*.xml build\classes\demo\restful\server&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/restful directory run the following commands. They &lt;br /&gt;
are entered on a single command line.&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.restful.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.restful.client.Client&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.restful.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.restful.client.Client&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.URI;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.dom.DOMSource;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
import javax.xml.ws.Dispatch;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import javax.xml.ws.handler.MessageContext;&lt;br /&gt;
import javax.xml.ws.http.HTTPBinding;&lt;br /&gt;
import org.w3c.dom.Document;&lt;br /&gt;
import org.apache.cxf.helpers.XMLUtils;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        QName serviceName = new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;,&lt;br /&gt;
                                                &amp;quot;cutomerservice&amp;quot;);&lt;br /&gt;
        QName portName = new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;,&lt;br /&gt;
                                             &amp;quot;RestProviderPort&amp;quot;);&lt;br /&gt;
        String endpointAddress = &amp;quot;http://localhost:9000/customerservice/customer&amp;quot;;&lt;br /&gt;
        // Sent HTTP GET request to query all customer info&lt;br /&gt;
        URL url = new URL(endpointAddress);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to query all customer info&amp;quot;);&lt;br /&gt;
        InputStream in = url.openStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to query customer info&lt;br /&gt;
        url = new URL(endpointAddress + &amp;quot;?id=1234&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to query customer info&amp;quot;);&lt;br /&gt;
        in = url.openStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP POST request to update customer info using JAX-WS Dispatch&lt;br /&gt;
        URI endpointURI = new URI(endpointAddress.toString());&lt;br /&gt;
        String path = null;&lt;br /&gt;
        if (endpointURI != null) {&lt;br /&gt;
            path = endpointURI.getPath();&lt;br /&gt;
        }&lt;br /&gt;
        Service service = Service.create(serviceName);&lt;br /&gt;
        service.addPort(portName, HTTPBinding.HTTP_BINDING,  endpointAddress);&lt;br /&gt;
        Dispatch&amp;lt;DOMSource&amp;gt; dispatcher = service.createDispatch(portName,&lt;br /&gt;
                                                                DOMSource.class, Service.Mode.PAYLOAD);&lt;br /&gt;
        Map&amp;lt;String, Object&amp;gt; requestContext = dispatcher.getRequestContext();&lt;br /&gt;
        Client client = new Client();&lt;br /&gt;
        InputStream is = client.getClass().getResourceAsStream(&amp;quot;CustomerJohnReq.xml&amp;quot;);&lt;br /&gt;
        Document doc = XMLUtils.parse(is);&lt;br /&gt;
        DOMSource reqMsg = new DOMSource(doc);&lt;br /&gt;
        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, &amp;quot;POST&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking through HTTP POST to update customer using JAX-WS Dispatch&amp;quot;);&lt;br /&gt;
        DOMSource result = dispatcher.invoke(reqMsg);&lt;br /&gt;
        printSource(result);&lt;br /&gt;
        System.out.println(&amp;quot;Client Invoking is succeeded!&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.server;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import javax.annotation.Resource;&lt;br /&gt;
import javax.xml.parsers.DocumentBuilder;&lt;br /&gt;
import javax.xml.parsers.DocumentBuilderFactory;&lt;br /&gt;
import javax.xml.transform.dom.DOMSource;&lt;br /&gt;
import javax.xml.ws.Provider;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import javax.xml.ws.ServiceMode;&lt;br /&gt;
import javax.xml.ws.WebServiceContext;&lt;br /&gt;
import javax.xml.ws.WebServiceProvider;&lt;br /&gt;
import javax.xml.ws.handler.MessageContext;&lt;br /&gt;
import org.w3c.dom.Document;&lt;br /&gt;
import org.apache.cxf.message.Message;&lt;br /&gt;
@WebServiceProvider()&lt;br /&gt;
@ServiceMode(value = Service.Mode.PAYLOAD)&lt;br /&gt;
public class RestSourcePayloadProvider implements Provider&amp;lt;DOMSource&amp;gt; {&lt;br /&gt;
    @Resource&lt;br /&gt;
    protected WebServiceContext wsContext;&lt;br /&gt;
    public RestSourcePayloadProvider() {&lt;br /&gt;
    }&lt;br /&gt;
    public DOMSource invoke(DOMSource request) {&lt;br /&gt;
        MessageContext mc = wsContext.getMessageContext();&lt;br /&gt;
        String path = (String)mc.get(Message.PATH_INFO);&lt;br /&gt;
        String query = (String)mc.get(Message.QUERY_STRING);&lt;br /&gt;
        String httpMethod = (String)mc.get(Message.HTTP_REQUEST_METHOD);&lt;br /&gt;
        System.out.println(&amp;quot;--path--- &amp;quot; + path);&lt;br /&gt;
        System.out.println(&amp;quot;--query--- &amp;quot; + query);&lt;br /&gt;
        System.out.println(&amp;quot;--httpMethod--- &amp;quot; + httpMethod);&lt;br /&gt;
        if (httpMethod.equalsIgnoreCase(&amp;quot;POST&amp;quot;)) {&lt;br /&gt;
            // TBD: parse query info from DOMSource&lt;br /&gt;
            System.out.println(&amp;quot;---Invoking updateCustomer---&amp;quot;);&lt;br /&gt;
            return updateCustomer(request);&lt;br /&gt;
        } else if (httpMethod.equalsIgnoreCase(&amp;quot;GET&amp;quot;)) {&lt;br /&gt;
            if (path.equals(&amp;quot;/customerservice/customer&amp;quot;) &amp;amp;&amp;amp; query == null) {&lt;br /&gt;
                System.out.println(&amp;quot;---Invoking getAllCustomers---&amp;quot;);&lt;br /&gt;
                return getAllCustomers();&lt;br /&gt;
            } else if (path.equals(&amp;quot;/customerservice/customer&amp;quot;) &amp;amp;&amp;amp; query != null) {&lt;br /&gt;
                System.out.println(&amp;quot;---Invoking getCustomer---&amp;quot;);&lt;br /&gt;
                return getCustomer(query);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource getAllCustomers() {&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerAllResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource getCustomer(String customerID) {&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerJohnResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource updateCustomer(DOMSource request) {&lt;br /&gt;
        // TBD: returned update customer info&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerJohnResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource createDOMSource(String fileName) {&lt;br /&gt;
        DocumentBuilderFactory factory;&lt;br /&gt;
        DocumentBuilder builder;&lt;br /&gt;
        Document document = null;&lt;br /&gt;
        DOMSource response = null;&lt;br /&gt;
        try {&lt;br /&gt;
            factory = DocumentBuilderFactory.newInstance();&lt;br /&gt;
            //factory.setValidating(true);&lt;br /&gt;
            builder = factory.newDocumentBuilder();&lt;br /&gt;
            InputStream greetMeResponse = getClass().getResourceAsStream(fileName);&lt;br /&gt;
            document = builder.parse(greetMeResponse);&lt;br /&gt;
            response = new DOMSource(document);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return response;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
import javax.xml.ws.http.HTTPBinding;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestSourcePayloadProvider());&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/customerservice/customer&amp;quot;;&lt;br /&gt;
        e.publish(address);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo shows how to create RESTful services using CXF&amp;quot;s HTTP binding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This demo shows how to create RESTful services using CXF&amp;quot;s HTTP binding.&lt;br /&gt;
The server in the demo creates 3 different endpoints: a RESTful XML&lt;br /&gt;
endpoint, a RESTful JSON endpoint, and a SOAP endpoint.&lt;br /&gt;
[RUNNING THE DEMO]&lt;br /&gt;
The demo has a class called com.acme.customer.Main which starts up various&lt;br /&gt;
endpoints. To start this server run the command:&lt;br /&gt;
$ ant server&lt;br /&gt;
Once it is running try going to the following URLs:&lt;br /&gt;
http://localhost:8080/xml/customers&lt;br /&gt;
http://localhost:8080/json/customers&lt;br /&gt;
http://localhost:8080/xml/customers/123&lt;br /&gt;
http://localhost:8080/json/customers/123&lt;br /&gt;
These will serve out XML and JSON representation of the resources.&lt;br /&gt;
There is an HTML page that is served by CXF so you can try using the&lt;br /&gt;
JSON service via Javascript. Just go to:&lt;br /&gt;
http://localhost:8080/test.html&lt;br /&gt;
Included are some example JSON and XML files so you can add or update&lt;br /&gt;
customers using wget. Try the following commands and look at the results:&lt;br /&gt;
wget --post-file add.json http://localhost:8080/json/customers&lt;br /&gt;
wget --post-file add.xml http://localhost:8080/xml/customers&lt;br /&gt;
wget --post-file update.xml http://localhost:8080/xml/customers/123&lt;br /&gt;
And if you are interested in SOAP you can try the SOAP endpoint:&lt;br /&gt;
http://localhost:8080/soap?wsdl&lt;br /&gt;
[RUNNING THE CLIENT]&lt;br /&gt;
The demo also includes a Client class which accesses data using &lt;br /&gt;
HTTP. To run this demo, do:&lt;br /&gt;
$ ant client&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>