You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by th...@apache.org on 2007/02/08 14:50:09 UTC

svn commit: r504897 - in /webservices/axis2/trunk/java/modules/samples/yahoojsonsearch: ./ resources/ src/ src/sample/ src/sample/yahooservices/ src/sample/yahooservices/JSONSearch/

Author: thilina
Date: Thu Feb  8 05:50:08 2007
New Revision: 504897

URL: http://svn.apache.org/viewvc?view=rev&rev=504897
Log:
Applying the patch given at https://issues.apache.org/jira/browse/AXIS2-2064
Thanx Isuru

Added:
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/README.txt
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/build.xml
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/axis2.xml
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchClient.java
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchModel.java
    webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/UserInterface.java

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/README.txt?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/README.txt (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/README.txt Thu Feb  8 05:50:08 2007
@@ -0,0 +1,24 @@
+Sample for Yahoo - Search - JSON
+=================================
+
+Introduction
+============
+
+Axis2 client API has facilities to accept responses in JSON.
+
+Yahoo provides an API to call its search service and retrieve JSON responses. This sample demonstrates how to call Yahoo
+search service using an Axis2 client which accepts a JSON response.
+
+Pre-Requisites
+==============
+
+Apache Ant 1.6.2 or later
+
+Running The Sample
+==================
+
+Type "ant" from Axis2_HOME/samples/yahoojsonsearch directory.
+
+Help
+====
+Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/build.xml?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/build.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/build.xml Thu Feb  8 05:50:08 2007
@@ -0,0 +1,32 @@
+<project name="YahooJSONSearchSample" default="run.client">
+	<property environment="env" />
+	<property name="axis2.home" value="../../" />
+	<property name="axis2.repo" value="${axis2.home}/repository" />
+	<property name="build.dir" value="build" />
+	<property name="client.classes.dir" value="${build.dir}/classes" />
+	<path id="axis.classpath">
+		<fileset dir="${axis2.home}/lib">
+			<include name="*.jar" />
+		</fileset>
+		<pathelement location="build/yahooJSONSearch.jar" />
+	</path>
+
+	<target name="compile">
+		<mkdir dir="${client.classes.dir}" />
+		<!-- Compile client -->
+		<javac srcdir="src" destdir="${client.classes.dir}">
+			<classpath refid="axis.classpath" />
+		</javac>
+		<jar destfile="${build.dir}/yahooJSONSearch.jar">
+			<fileset dir="${build.dir}/classes" />
+		</jar>
+	</target>
+	<target name="run.client" depends="compile">
+		<java classname="sample.yahooservices.JSONSearch.JSONSearchClient" classpathref="axis.classpath" fork="true">
+			<jvmarg value="-Daxis2.repo=${axis2.repo}" />
+		</java>
+	</target>
+	<target name="clean">
+		<delete dir="build" />
+	</target>
+</project>

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/axis2.xml?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/axis2.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/resources/axis2.xml Thu Feb  8 05:50:08 2007
@@ -0,0 +1,345 @@
+<!--
+/*
+ * Copyright 2001-2004 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.
+ */
+ -->
+ 
+<axisconfig name="AxisJava2.0">
+    <!-- ================================================= -->
+    <!-- Parameters -->
+    <!-- ================================================= -->
+    <parameter name="hotdeployment" locked="false">true</parameter>
+    <parameter name="hotupdate" locked="false">false</parameter>
+    <parameter name="enableMTOM" locked="false">false</parameter>
+    <parameter name="enableSwA" locked="false">false</parameter>
+
+    <!--Uncomment if you want to enable file caching for attachments -->
+    <!--parameter name="cacheAttachments" locked="false">true</parameter>
+    <parameter name="attachmentDIR" locked="false"></parameter>
+    <parameter name="sizeThreshold" locked="false">4000</parameter-->
+
+    <!--This will give out the timout of the configuration contexts, in seconds-->
+    <parameter name="ConfigContextTimeoutInterval" locked="false">30</parameter>
+
+    <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+    <!--that behaviour.-->
+    <parameter name="sendStacktraceDetailsWithFaults" locked="false">false</parameter>
+
+    <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+    <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+    <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+    <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+    <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
+
+    <parameter name="userName" locked="false">admin</parameter>
+    <parameter name="password" locked="false">axis2</parameter>
+
+    <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
+    <!--<parameter name="ServicesDirectory" locked="false">service</parameter>-->
+    <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
+    <!--<parameter name="ModulesDirectory" locked="false">modules</parameter>-->
+
+
+
+    <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+    <!--root which can configured using the following contextRoot parameter-->
+    <!--<parameter name="contextRoot" locked="false">axis2</parameter>-->
+
+    <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distingiush those endpoints-->
+    <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+    <!--context path to proper Axis2 servlets-->
+    <!--<parameter name="servicePath" locked="false">services</parameter>-->
+    <!--<parameter name="restPath" locked="false">rest</parameter>-->
+
+
+    <!--Set the flag to true if you want to enable transport level session mangment-->
+    <parameter name="manageTransportSession" locked="false">false</parameter>
+
+    <!--Following two parameters will be used to handle REST in Axis2. The default settings will make Axis2 to have two-->
+    <!--different endpoints, one for REST (AxisRESTServlet) one for SOAP message handling (AxisServlet). But following-->
+    <!--parameters help to tweak the message handling of two main servlets. -->
+
+    <!-- If the enableRESTInAxis2MainServlet is true, then Axis2MainServlet will handle both SOAP and REST messages -->
+    <parameter name="enableRESTInAxis2MainServlet" locked="true">false</parameter>
+
+    <!-- Following parameter will completely disable REST handling in both the servlets-->
+    <parameter name="disableREST" locked="true">false</parameter>
+
+    <!-- This will disable the separate servlet we have for REST handling. -->
+    <parameter name="disableSeparateEndpointForREST" locked="true">false</parameter>
+
+    <!-- If you have a frontend host which exposes this webservice using a different public URL  -->
+    <!-- use this parameter to override autodetected url -->
+    <!--<parameter name="httpFrontendHostUrl" locked="false">https://someotherhost/context</parameter>-->
+
+
+    <!--    The way of adding listener to the system-->
+    <!--    <listener class="org.apache.axis2.ObserverIMPL">-->
+    <!--        <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+    <!--    </listener>-->
+
+    <!-- ================================================= -->
+    <!-- Message Receivers -->
+    <!-- ================================================= -->
+    <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+    <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+    <!--any operation -->
+    <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+    <messageReceivers>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+    </messageReceivers>
+    
+    <!-- ================================================= -->
+    <!-- Message Formatter -->
+    <!-- ================================================= -->
+    <!--Following content type to message formatter mapping can be used to implement support for different message -->
+    <!--formats  serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
+    <messageFormatters>
+        <messageFormatter contentType="application/soap+xml"
+                         class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+        <messageFormatter contentType="application/json"
+                         class="org.apache.axis2.json.JSONMessageFormatter"/>
+        <messageFormatter contentType="application/json/badgerfish"
+                         class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
+        <messageFormatter contentType="text/javascript"
+                         class="org.apache.axis2.json.JSONMessageFormatter"/>
+    </messageFormatters>
+    
+    <!-- ================================================= -->
+    <!-- Message Builders -->
+    <!-- ================================================= -->
+    <!--Following content type to builder mapping can be used to implement support for different message -->
+    <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
+    <messageBuilders>
+        <messageBuilder contentType="application/json"
+                         class="org.apache.axis2.json.JSONOMBuilder"/>
+        <messageBuilder contentType="application/json/badgerfish"
+                         class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
+        <messageBuilder contentType="text/javascript"
+                         class="org.apache.axis2.json.JSONOMBuilder"/>
+        <messageBuilder contentType="application/soap+xml"
+                         class="org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder"/>
+    </messageBuilders>
+    
+    <!-- ================================================= -->
+    <!-- Transport Ins -->
+    <!-- ================================================= -->
+    <transportReceiver name="http"
+                       class="org.apache.axis2.transport.http.SimpleHTTPServer">
+        <parameter name="port" locked="false">8080</parameter>
+        <!-- Here is the complete list of supported parameters (see example settings further below):
+            port: the port to listen on (default 6060)
+            hostname:  if non-null, url prefix used in reply-to endpoint references                                 (default null)
+            originServer:  value of http Server header in outgoing messages                                         (default "Simple-Server/1.1")
+            requestTimeout:  value in millis of time that requests can wait for data                                (default 20000)
+            requestTcpNoDelay:  true to maximize performance and minimize latency                                   (default true)
+                                false to minimize bandwidth consumption by combining segments
+            requestCoreThreadPoolSize:  number of threads available for request processing (unless queue fills up)  (default 25)
+            requestMaxThreadPoolSize:  number of threads available for request processing if queue fills us         (default 150)
+                                       note that default queue never fills up:  see HttpFactory
+            threadKeepAliveTime:  time to keep threads in excess of core size alive while inactive                  (default 180)
+                                  note that no such threads can exist with default unbounded request queue
+            threadKeepAliveTimeUnit:  TimeUnit of value in threadKeepAliveTime (default SECONDS)                    (default SECONDS)
+        -->
+        <!-- <parameter name="hostname"                  locked="false">http://www.myApp.com/ws</parameter> -->
+        <!-- <parameter name="originServer"              locked="false">My-Server/1.1</parameter>           -->
+        <!-- <parameter name="requestTimeout"            locked="false">10000</parameter>                   -->
+        <!-- <parameter name="requestTcpNoDelay"         locked="false">false</parameter>                   -->
+        <!-- <parameter name="requestCoreThreadPoolSize" locked="false">50</parameter>                      -->
+        <!-- <parameter name="RequestMaxThreadPoolSize"  locked="false">100</parameter>                     -->
+        <!-- <parameter name="threadKeepAliveTime"       locked="false">240000</parameter>                  -->
+        <!-- <parameter name="threadKeepAliveTimeUnit"   locked="false">MILLISECONDS</parameter>            -->
+    </transportReceiver>
+    
+    <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)
+    <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
+        <parameter name="myTopicConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="myQueueConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="default" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+    </transportReceiver>-->
+
+    <!--Uncomment if you want to have SMTP transport support-->
+    <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+    <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+    <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+    <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+    <!--</transportReceiver>-->
+
+	<!--Uncomment if you want to have TCP transport support-->
+    <!--transportReceiver name="tcp"
+                       class="org.apache.axis2.transport.tcp.TCPServer">
+        <parameter name="port" locked="false">6060</parameter-->>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+    <!-- /transportReceiver -->
+
+    <!-- ================================================= -->
+    <!-- Transport Outs -->
+    <!-- ================================================= -->
+
+    <transportSender name="tcp"
+                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+    <transportSender name="local"
+                     class="org.apache.axis2.transport.local.LocalTransportSender"/>
+    <transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+    </transportSender>
+    <transportSender name="https"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+    </transportSender>
+    <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)
+    <transportSender name="jms"
+                     class="org.apache.axis2.transport.jms.JMSSender"/>
+    -->
+
+    <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+   <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+       <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+       <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+       <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+       <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+   </transportSender>
+   -->
+
+    <!-- ================================================= -->
+    <!-- Global Modules  -->
+    <!-- ================================================= -->
+    <!-- Comment this to disable Addressing -->
+    <!--module ref="addressing"/-->
+
+    <!--Configuring module , providing parameters for modules whether they refer or not-->
+    <!--<moduleConfig name="addressing">-->
+    <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+    <!--</moduleConfig>-->
+
+    <!-- ================================================= -->
+    <!-- Phases  -->
+    <!-- ================================================= -->
+    <phaseOrder type="InFlow">
+        <!--  System pre defined phases       -->
+        <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+                <order phase="Transport"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.engine.AddressingBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.engine.RequestURIOperationDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="InstanceDispatcher"
+                     class="org.apache.axis2.engine.InstanceDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+        </phase>
+        <!--  System pre defined phases       -->
+        <!--   After Postdispatch phase module author or or service author can add any phase he want      -->
+        <phase name="OperationInPhase"/>
+	<phase name="soapmonitorPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFlow">
+        <!--      user can add his own phases to this area  -->
+	<phase name="soapmonitorPhase"/>
+        <phase name="OperationOutPhase"/>
+        <!--system predefined phase-->
+        <!--these phase will run irrespective of the service-->
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+        <phase name="Security"/>
+    </phaseOrder>
+    <phaseOrder type="InFaultFlow">
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.engine.AddressingBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="RequestURIOperationDispatcher"
+                     class="org.apache.axis2.engine.RequestURIOperationDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="InstanceDispatcher"
+                     class="org.apache.axis2.engine.InstanceDispatcher">
+                <order phase="PostDispatch"/>
+            </handler>
+        </phase>
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationInFaultPhase"/>
+	<phase name="soapmonitorPhase"/>
+    </phaseOrder>
+    <phaseOrder type="OutFaultFlow">
+        <!--      user can add his own phases to this area  -->
+	<phase name="soapmonitorPhase"/>
+        <phase name="OperationOutFaultPhase"/>
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+    </phaseOrder>
+</axisconfig>
+

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchClient.java?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchClient.java (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchClient.java Thu Feb  8 05:50:08 2007
@@ -0,0 +1,47 @@
+/*
+ * 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 sample.yahooservices.JSONSearch;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class JSONSearchClient extends JFrame {
+    public static int width;
+    public static int height;
+
+    public JSONSearchClient(String title) throws HeadlessException {
+        super(title);
+
+        this.getContentPane().add(new UserInterface(this));
+        this.setVisible(true);
+    }
+
+    public static void main(String[] args) {
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        width = screenSize.width;
+        height = screenSize.height;
+        JSONSearchClient form = new JSONSearchClient("Axis2 Yahoo-JSON Search Client");
+
+
+        int left = (width) / 2;
+        int top = (height) / 2;
+        form.setLocation(left, top);
+        form.setSize(width, height);
+        form.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+        form.setVisible(true);
+    }
+}

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchModel.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchModel.java?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchModel.java (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/JSONSearchModel.java Thu Feb  8 05:50:08 2007
@@ -0,0 +1,126 @@
+/*
+* 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 sample.yahooservices.JSONSearch;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+
+import java.io.UnsupportedEncodingException;
+import java.io.File;
+import java.net.URLEncoder;
+import java.util.Iterator;
+
+public class JSONSearchModel {
+    /**
+     * HTML Header to desplay snippet text
+     */
+    private String beginHTML = "<HTML><HEAD><TITLE>Search Results</TITLE></HEAD><BODY>";
+
+    /**
+     * HTML footer
+     */
+    private String endHTML = "</BODY></HTML>";
+
+    /**
+     * Store the texts read by NavigationURL of soap
+     */
+    private String snippet;
+
+    public String searchYahoo(String query, String format) {
+        try {
+            snippet = beginHTML;
+//            String epr = "http://localhost:8060/WebSearchService/V1/webSearch";
+            String epr = "http://api.search.yahoo.com/WebSearchService/V1/webSearch";
+//            File configFile = new File("modules/json/test-resources/axis2.xml");
+            File configFile = new File("resources/axis2.xml");
+            ConfigurationContext configurationContext = ConfigurationContextFactory
+                    .createConfigurationContextFromFileSystem(null, configFile
+                            .getAbsolutePath());
+
+            ServiceClient client = new ServiceClient(configurationContext, null);
+            Options options = new Options();
+            client.setOptions(options);
+            options.setTo(new EndpointReference(epr));
+            options.setProperty(Constants.Configuration.MESSAGE_TYPE, "text/javascript");
+            options.setProperty(Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET);
+            OMElement response = client.sendReceive(getPayloadForYahooSearchCall(query, format));
+            System.out.println(response);
+            generateSnippet(response);
+            return snippet;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            snippet = "<H2>Error occurred during the invocation to Yahoo search service</H2>" +
+                    "<p>" + e.getMessage() + "</p>" + endHTML;
+        }
+        return null;
+    }
+
+    private static OMElement getPayloadForYahooSearchCall(String queryStr, String formatStr) throws UnsupportedEncodingException {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement rootElement = fac.createOMElement("webSearch", null);
+
+        OMElement appId = fac.createOMElement("appid", null, rootElement);
+        appId.setText("ApacheRestDemo");
+
+        OMElement query = fac.createOMElement("query", null, rootElement);
+        query.setText(URLEncoder.encode(queryStr, "UTF-8"));
+
+        OMElement outputType = fac.createOMElement("output", null, rootElement);
+        outputType.setText("json");
+
+        if (formatStr != null && formatStr.length() != 0) {
+            OMElement format = fac.createOMElement("format", null, rootElement);
+            format.setText(URLEncoder.encode(formatStr, "UTF-8"));
+        }
+        return rootElement;
+    }
+
+    private void generateSnippet(OMElement response) {
+        String title = null;
+        String summary = null;
+        String clickUrl = null;
+        String url = null;
+        OMElement result = null;
+        //get an iterator for Result elements
+        Iterator itr = response.getChildElements();
+        Iterator innerItr;
+        while (itr.hasNext()) {
+            result = (OMElement) itr.next();
+            innerItr = result.getChildElements();
+            if (innerItr.hasNext()) {
+                title = ((OMElement) innerItr.next()).getText();
+                summary = ((OMElement) innerItr.next()).getText();
+                url = ((OMElement) innerItr.next()).getText();
+                clickUrl = ((OMElement) innerItr.next()).getText();
+                if (title != null) {
+                    snippet += "<a href=" + clickUrl + ">" + title + "</a>" + "<br>" + summary +
+                            "<br>" + url + "<br>" + "<br>";
+                }
+            }
+        }
+        snippet += endHTML;
+    }
+}
+

Added: webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/UserInterface.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/UserInterface.java?view=auto&rev=504897
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/UserInterface.java (added)
+++ webservices/axis2/trunk/java/modules/samples/yahoojsonsearch/src/sample/yahooservices/JSONSearch/UserInterface.java Thu Feb  8 05:50:08 2007
@@ -0,0 +1,132 @@
+/*
+ * 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 sample.yahooservices.JSONSearch;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.event.HyperlinkEvent;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+public class UserInterface extends JPanel implements HyperlinkListener {
+
+    private JEditorPane jep;
+    private JScrollPane scrollPane;
+
+    private JTextField schField;
+    private JTextField formatField;
+
+    private JButton schButton;
+    private JButton backButton;
+
+    private JLabel schLabel;
+    private JLabel formatLabel;
+
+
+    private JSONSearchModel model;
+    private JSONSearchClient parent;
+
+    private String response;
+    public UserInterface(JSONSearchClient parent) {
+        this.parent = parent;
+        model =  new JSONSearchModel();
+        initComponents();
+
+        schButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                handleSearch();
+            }
+        });
+
+        backButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                handleBack();
+            }
+        });
+
+        Container pane = parent.getContentPane();
+        pane.setLayout(null);
+
+        pane.add(schLabel);
+        pane.add(schField);
+        pane.add(formatLabel);
+        pane.add(formatField);
+        pane.add(backButton);
+        pane.add(schButton);
+        pane.add(scrollPane);
+    }
+
+    public void initComponents() {
+        schLabel = new JLabel("Search for");
+        schLabel.setBounds(20, 10, 80, 25);
+        schField = new JTextField();
+        schField.setBounds(90, 10, 250, 25);
+
+        formatLabel = new JLabel("format");
+        formatLabel.setBounds(350, 10, 50, 25);
+        formatField = new JTextField();
+        formatField.setBounds(400, 10, 100, 25);
+
+        backButton = new JButton("Back to Results");
+        backButton.setBounds(670, 10, 150, 25);
+        backButton.setEnabled(false);
+
+        schButton =  new JButton("Search");
+        schButton.setBounds(510, 10, 150, 25);
+
+
+        jep = new JEditorPane();
+        jep.setEditable(false);
+        jep.setContentType("text/html");
+        jep.addHyperlinkListener(this);
+
+        scrollPane = new JScrollPane(jep);
+        scrollPane.setBounds(10, 80, (JSONSearchClient.width - 30), (JSONSearchClient.height - 160));
+
+
+    }
+
+    private void handleSearch(){
+        String query = schField.getText();
+
+        if(!query.equals("")){
+            response = model.searchYahoo(query, formatField.getText());
+            jep.setText(response);
+        }
+    }
+
+    private void handleBack(){
+        jep.setText(response);
+        backButton.setEnabled(false);
+    }
+
+    public void hyperlinkUpdate(HyperlinkEvent he) {
+        if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+            try {
+                jep.setPage(he.getURL());
+                backButton.setEnabled(true);
+            }
+            catch (Exception e) {
+                  JOptionPane.showMessageDialog(parent, "Page could not be loaded",
+                                "Page Error", JOptionPane.ERROR_MESSAGE);
+            }
+        }
+
+    }
+}
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org