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 ch...@apache.org on 2005/01/28 05:15:15 UTC
svn commit: r148850 - in webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples: userguide/example1 utils
Author: chathura
Date: Thu Jan 27 20:15:14 2005
New Revision: 148850
URL: http://svn.apache.org/viewcvs?view=rev&rev=148850
Log:
Intermediary Commit sharing. Basic server and client stubs are in place for the Echo Sample.
Added:
webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/InteropTest_Stub.java
webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/SampleEnvironmentCreator.java
webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/TestServer.java
Modified:
webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java
webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java?view=diff&rev=148850&p1=webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java&r1=148849&p2=webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java&r2=148850
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/EchoString.java Thu Jan 27 20:15:14 2005
@@ -15,12 +15,26 @@
*/
package org.apache.axis.samples.userguide.example1;
+import java.net.URL;
+
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.engine.EngineUtils;
+
/**
* @author chathura@opensource.lk
*
*/
public class EchoString {
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception{
+ InteropTest_Stub stub =new InteropTest_Stub();
+ URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
+ stub.setEnePointReference(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+ stub.echoString("does this damn think work");
+
+
}
+
+
}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/InteropTest_Stub.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/InteropTest_Stub.java?view=auto&rev=148850
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/InteropTest_Stub.java Thu Jan 27 20:15:14 2005
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+package org.apache.axis.samples.userguide.example1;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.samples.utils.OMUtil;
+
+/**
+ * This file is hand written for the M1 demp purposes and will be
+ * auto generated fron WSDLx4Java tool.
+ *
+ */
+public class InteropTest_Stub {
+
+ private OMFactory omFactory = OMFactory.newInstance();
+ private Call call = new Call();
+
+
+
+
+ //////////////////////User setter methods//////////////////////
+
+ public void setEnePointReference(EndpointReference epr){
+ this.call.setTo(epr);
+ }
+
+ //\\\\\\\\\\\\\\\\\\End user setter methods\\\\\\\\\\\\\\\\\\//
+
+
+ /////////////////////Webservice Operations/////////////////////
+
+ public java.lang.String echoString(java.lang.String inputValue)throws AxisFault{
+ this.validate();
+ SOAPEnvelope responceEnvelop = call.sendReceive(this.getSOAPEnvelopForEchoString(inputValue));
+ return this.getEchoStringFromSOAPEnvelop(responceEnvelop);
+
+
+
+ }
+ //\\\\\\\\\\\\\\\\End Webservice Operations\\\\\\\\\\\\\\\\\\//
+
+
+
+
+
+
+ ////////////////////////////////////////////////////////////////
+ // Util Methods //
+ ////////////////////////////////////////////////////////////////
+
+
+ protected SOAPEnvelope getSOAPEnvelopForEchoString(String value){
+ SOAPEnvelope envelop = OMUtil.getEmptySoapEnvelop();
+ OMNamespace interopNamespace = envelop.declareNamespace("http://soapinterop.org/", "interop");
+ OMElement echoStringMessage = omFactory.createOMElement("echoStringRequest", interopNamespace);
+ OMElement text = omFactory.createOMElement("Text", null);
+ text.addChild(omFactory.createText(value));
+ echoStringMessage.addChild(text);
+ envelop.addChild(echoStringMessage);
+ return envelop;
+ }
+
+ protected String getEchoStringFromSOAPEnvelop(SOAPEnvelope envelop){
+ OMElement body = envelop.getBody();
+ OMElement response = null;
+ Iterator childrenIter = body.getChildren();
+ while(childrenIter.hasNext()){
+ OMNode child = (OMNode) childrenIter.next();
+ if(child instanceof OMElement && "echoStringResponse".equalsIgnoreCase(((OMElement)child).getLocalName())){
+ response = (OMElement)child;
+ }
+ }
+
+ Iterator textChild = response.getChildrenWithName(new QName("", "Text"));
+ String value= null;
+ if(textChild.hasNext()){
+ value = ((String)((OMElement)textChild.next()).getValue());
+ }
+ return value;
+
+ }
+
+
+
+ protected void validate() throws AxisFault{
+ String errorMessage = null;
+
+ if(null == this.call.getTO())
+ errorMessage = "End Point reference is not set: ";
+
+
+
+ if(null != errorMessage){
+ errorMessage = "One or more Errors occured :: "+ errorMessage;
+ throw new AxisFault(errorMessage);
+ }
+
+
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/SampleEnvironmentCreator.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/SampleEnvironmentCreator.java?view=auto&rev=148850
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/SampleEnvironmentCreator.java Thu Jan 27 20:15:14 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+package org.apache.axis.samples.userguide.example1;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.AxisGlobal;
+import org.apache.axis.description.AxisOperation;
+import org.apache.axis.engine.Echo;
+import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.engine.EngineUtils;
+import org.apache.axis.impl.description.AxisService;
+import org.apache.axis.impl.description.SimpleAxisOperationImpl;
+import org.apache.axis.impl.providers.SimpleJavaProvider;
+import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author chathura@opensource.lk
+ *
+ */
+public class SampleEnvironmentCreator {
+
+ private Log log = LogFactory.getLog(getClass());
+ private QName serviceName = new QName("","InteropService");
+ private QName operationName1 = new QName("http://localhost/my","echoInt");
+ private QName operationName2 = new QName("http://localhost/my","echoString");
+ private QName transportName = new QName("http://localhost/my","NullTransport");
+
+ private EngineRegistry engineRegistry;
+ private MessageContext mc;
+ private Thread thisThread = null;
+ private SimpleHTTPReceiver sas;
+
+
+ protected void setUp() throws Exception {
+ AxisGlobal global = new AxisGlobal();
+ engineRegistry = new org.apache.axis.impl.engine.EngineRegistryImpl(global);
+
+ AxisService service = new AxisService(serviceName);
+ service.setClassLoader(Thread.currentThread().getContextClassLoader());
+ service.setServiceClass(Echo.class);
+ service.setProvider(new SimpleJavaProvider());
+
+ AxisOperation operation1 = new SimpleAxisOperationImpl(operationName1);
+ service.addOperation(operation1);
+
+ AxisOperation operation2 = new SimpleAxisOperationImpl(operationName2);
+ service.addOperation(operation2);
+
+ EngineUtils.createExecutionChains(service);
+ engineRegistry.addService(service);
+
+ sas = EngineUtils.startServer(engineRegistry);
+
+
+ }
+
+
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/TestServer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/TestServer.java?view=auto&rev=148850
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/userguide/example1/TestServer.java Thu Jan 27 20:15:14 2005
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.axis.samples.userguide.example1;
+
+import org.apache.axis.engine.EngineUtils;
+
+/**
+ * @author chathura@opensource.lk
+ *
+ */
+public class TestServer {
+
+ public static void main(String[] args) throws Exception {
+
+ new SampleEnvironmentCreator().setUp();
+ Thread.sleep(150000);
+ }
+
+ protected void tearDown() throws Exception {
+ EngineUtils.stopServer();
+ Thread.sleep(1000);
+ System.out.println("Server shuting down......");
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java?view=diff&rev=148850&p1=webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java&r1=148849&p2=webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java&r2=148850
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/samples/org/apache/axis/samples/utils/OMUtil.java Thu Jan 27 20:15:14 2005
@@ -28,14 +28,14 @@
public class OMUtil {
- private String basicSOAPXML = "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\"> \n" +
+ private static final String basicSOAPXML = "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" +
" <env:Header>\n" +
" </env:Header>\n" +
" <env:Body>\n" +
" </env:Body>\n" +
"</env:Envelope>";
- public SOAPEnvelope getEmptySoapEnvelop(){
+ public static SOAPEnvelope getEmptySoapEnvelop(){
XMLStreamReader parser = null;
try {
parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(basicSOAPXML));