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 ja...@apache.org on 2005/06/03 12:25:18 UTC
svn commit: r179765 - in
/webservices/axis/trunk/java/modules/samples/src/userguide: clients/
clients/ClientUtil.java clients/EchoClient.java clients/PingClient.java
example1/META-INF/service.xml example1/MyService.java example2/
example2/META-INF/ example2/META-INF/service.xml example2/MyService.java
Author: jaliya
Date: Fri Jun 3 03:25:15 2005
New Revision: 179765
URL: http://svn.apache.org/viewcvs?rev=179765&view=rev
Log:
Sample Services
Added:
webservices/axis/trunk/java/modules/samples/src/userguide/clients/
webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientUtil.java
webservices/axis/trunk/java/modules/samples/src/userguide/clients/EchoClient.java
webservices/axis/trunk/java/modules/samples/src/userguide/clients/PingClient.java
webservices/axis/trunk/java/modules/samples/src/userguide/example2/
webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/
webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/service.xml
webservices/axis/trunk/java/modules/samples/src/userguide/example2/MyService.java
Modified:
webservices/axis/trunk/java/modules/samples/src/userguide/example1/META-INF/service.xml
webservices/axis/trunk/java/modules/samples/src/userguide/example1/MyService.java
Added: webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientUtil.java?rev=179765&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientUtil.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientUtil.java Fri Jun 3 03:25:15 2005
@@ -0,0 +1,52 @@
+
+package userguide.clients;
+
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
+
+/*
+ * 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.
+ */
+
+
+public class ClientUtil {
+
+ public static OMElement getEchoOMElement(){
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://example1.org/example1", "example1");
+ OMElement method = fac.createOMElement("echo", omNs);
+ OMElement value = fac.createOMElement("Text", omNs);
+ value.addChild(fac.createText(value, "Axis2 Echo String "));
+ method.addChild(value);
+
+ return method;
+ }
+ public static OMElement getPingOMElement(){
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://example1.org/example1", "example1");
+ OMElement method = fac.createOMElement("ping", omNs);
+ OMElement value = fac.createOMElement("Text", omNs);
+ value.addChild(fac.createText(value, "Axis2 Ping String "));
+ method.addChild(value);
+
+ return method;
+ }
+
+
+}
Added: webservices/axis/trunk/java/modules/samples/src/userguide/clients/EchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/clients/EchoClient.java?rev=179765&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/clients/EchoClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/clients/EchoClient.java Fri Jun 3 03:25:15 2005
@@ -0,0 +1,67 @@
+package userguide.clients;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMElement;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.StringWriter;
+
+/*
+ * 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.
+ */
+
+
+public class EchoClient {
+ private static String IP="http://127.0.0.1:8080";
+ private static EndpointReference targetEPR = new EndpointReference(AddressingConstants.WSA_TO,
+ IP + "/axis2/services/MyService/echo");
+ private static QName operationName = new QName("echo");
+ private static String value;
+
+ public static void main(String[] args) throws AxisFault {
+
+ try {
+ OMElement payload = ClientUtil.getEchoOMElement();
+ Call call = new Call();
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+
+ OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(),
+ payload);
+ StringWriter writer = new StringWriter();
+ result.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
+ writer.flush();
+ value= writer.toString();
+ System.out.println(value);
+
+ } catch (AxisFault axisFault) {
+ value = axisFault.getMessage();
+
+ } catch (XMLStreamException e) {
+ value = e.getMessage();
+
+ }
+
+ }
+
+
+}
Added: webservices/axis/trunk/java/modules/samples/src/userguide/clients/PingClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/clients/PingClient.java?rev=179765&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/clients/PingClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/clients/PingClient.java Fri Jun 3 03:25:15 2005
@@ -0,0 +1,53 @@
+package userguide.clients;
+
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.clientapi.MessageSender;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.Constants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.soap.SOAPEnvelope;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.namespace.QName;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.StringWriter;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Jaliya
+ * Date: Jun 3, 2005
+ * Time: 2:11:25 PM
+ */
+public class PingClient {
+ private static String IP="http://127.0.0.1:8080";
+ private static EndpointReference targetEPR = new EndpointReference(AddressingConstants.WSA_TO,
+ IP + "/axis2/services/MyService/echo");
+ private static QName operationName = new QName("echo");
+ private static String value;
+ public static void main(String[] args) throws AxisFault{
+
+ try {
+ OMElement payload = ClientUtil.getPingOMElement();
+
+ MessageSender msgSender= new MessageSender();
+ msgSender.setTo(targetEPR);
+ msgSender.setSenderTransport(Constants.TRANSPORT_HTTP);
+
+ msgSender.send("ping",payload);
+
+
+
+ } catch (AxisFault axisFault) {
+ value = axisFault.getMessage();
+
+ }
+ }
+
+
+}
Modified: webservices/axis/trunk/java/modules/samples/src/userguide/example1/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/example1/META-INF/service.xml?rev=179765&r1=179764&r2=179765&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/example1/META-INF/service.xml (original)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/example1/META-INF/service.xml Fri Jun 3 03:25:15 2005
@@ -7,6 +7,6 @@
<messageReceiver class="org.apache.axis.receivers.RawXMLINOutMessageRecevier"/>
</operation>
<operation name="ping">
- <messageReceiver class="org.apache.axis.receivers..RawXMLINOutMessageRecevier"/>
+ <messageReceiver class="org.apache.axis.receivers.RawXMLINOutMessageRecevier"/>
</operation>
</service>
Modified: webservices/axis/trunk/java/modules/samples/src/userguide/example1/MyService.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/example1/MyService.java?rev=179765&r1=179764&r2=179765&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/example1/MyService.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/example1/MyService.java Fri Jun 3 03:25:15 2005
@@ -2,6 +2,10 @@
import org.apache.axis.om.OMElement;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.StringWriter;
+
/**
* Created by IntelliJ IDEA.
* User: Jaliya
@@ -9,13 +13,20 @@
* Time: 2:17:58 PM
*/
public class MyService {
- public OMElement echo(OMElement element){
+ public OMElement echo(OMElement element) throws XMLStreamException {
+
+ StringWriter writer = new StringWriter();
+ element.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
+ writer.flush();
+
+ System.out.println(writer.toString());
+
element.getNextSibling();
element.detach();
return element;
}
- public void ping(OMElement element){
- //Do the ping
+ public void ping(OMElement element) {
+ //Do the ping
}
}
Added: webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/service.xml?rev=179765&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/service.xml (added)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/example2/META-INF/service.xml Fri Jun 3 03:25:15 2005
@@ -0,0 +1,12 @@
+<service name="MyService">
+ <description>
+ This is a sample Web Service with two operations,echo and ping.
+ </description>
+ <parameter name="ServiceClass" locked="xsd:false">userguide.example1.MyService</parameter>
+ <operation name="echo">
+ <messageReceiver class="org.apache.axis.receivers.RawXMLINOutMessageRecevier"/>
+ </operation>
+ <operation name="ping">
+ <messageReceiver class="org.apache.axis.receivers.RawXMLINOutMessageRecevier"/>
+ </operation>
+ </service>
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/samples/src/userguide/example2/MyService.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/example2/MyService.java?rev=179765&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/example2/MyService.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/example2/MyService.java Fri Jun 3 03:25:15 2005
@@ -0,0 +1,10 @@
+package userguide.example2;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Jaliya
+ * Date: Jun 3, 2005
+ * Time: 2:41:19 PM
+ */
+public class MyService {
+}