Hi all,
Client API being updated to support REST services. A sample also added.
Please apply this patch.
Saminda
Index: clientapi/RESTCall.java
===================================================================
--- clientapi/RESTCall.java (revision 0)
+++ clientapi/RESTCall.java (revision 0)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.clientapi;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ServiceContext;
+
+
+public class RESTCall extends Call {
+
+ public RESTCall() throws AxisFault {
+ super();
+ }
+
+ public RESTCall(ServiceContext service) throws AxisFault {
+ super(service);
+ }
+
+ public OMElement invokeBlocking()
+ throws AxisFault {
+ return super.invokeBlocking(
+ "nothing",
+ OMAbstractFactory.getOMFactory().createOMElement(
+ "nothing", "nothing", "nothing"));
+
+ }
+
+ public void invokeNonBlocking(Callback callback)
+ throws AxisFault {
+ super.invokeNonBlocking(
+ "nothing",
+ OMAbstractFactory.getOMFactory().createOMElement(
+ "nothing", "nothing", "nothing"), callback);
+
+ }
+}
\ No newline at end of file
Index: sample/yahooservices/RESTSearch/RESTSearchClient.java
===================================================================
--- sample/yahooservices/RESTSearch/RESTSearchClient.java (revision
227190)
+++ sample/yahooservices/RESTSearch/RESTSearchClient.java (working copy)
@@ -4,13 +4,17 @@
import javax.xml.stream.XMLStreamWriter;
import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.clientapi.RESTCall;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.impl.OMOutputImpl;
+import java.net.URL;
+
/**
* Created by IntelliJ IDEA.
* User: saminda
@@ -19,22 +23,19 @@
* To change this template use File | Settings | File Templates.
*/
public class RESTSearchClient {
- private static String eprGet =
-
"http://api.search.yahooservices.com/WebSearchService/V1/webSearch?appid=ApacheRestDemo&query=finances&format=pdf";
+ public static void main(String[] args) {
+ try{
+ String epr =
"http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=ApacheRestDemo&query=finances&format=pdf";
-
- public static void main(String[] args) {
- try{
- Call call = new Call();
- call.setTo(new EndpointReference(eprGet));
+ RESTCall call = new RESTCall();
+ call.setTo(new EndpointReference(epr));
call.setTransportInfo(Constants.TRANSPORT_HTTP,Constants.TRANSPORT_HTTP, false);
call.setDoREST(true);
call.setRestThroughPOST(false);
//if post is through GET of HTTP
- OMElement response =
call.invokeBlocking("",OMAbstractFactory.getOMFactory().createOMElement("","",""));
-
+ OMElement response = call.invokeBlocking();
XMLStreamWriter writer =
XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
response.serializeWithCache(new OMOutputImpl(writer));
writer.flush();