You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mirae-dev@ws.apache.org by ia...@apache.org on 2005/09/03 07:27:13 UTC

svn commit: r267424 - /webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java

Author: ias
Date: Fri Sep  2 22:27:10 2005
New Revision: 267424

URL: http://svn.apache.org/viewcvs?rev=267424&view=rev
Log:
Revised to support generic stream.

Modified:
    webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java

Modified: webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java?rev=267424&r1=267423&r2=267424&view=diff
==============================================================================
--- webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java (original)
+++ webservices/mirae/trunk/src/mirae/ws/org/apache/mirae/ws/Dispatch.java Fri Sep  2 22:27:10 2005
@@ -1,25 +1,10 @@
-/*
- * Copyright 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.mirae.ws;
 
 import java.io.IOException;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
+import javax.microedition.io.StreamConnection;
 import javax.xml.rpc.NamespaceConstants;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -31,15 +16,19 @@
 import org.apache.mirae.ws.util.Base64;
 
 public class Dispatch {
-    private HttpConnection connection;
+    private StreamConnection connection;
 
     public Dispatch(String endpointUrl, String soapAction) throws IOException {
         this(endpointUrl, soapAction, null, null);
     }
     
+    public Dispatch(StreamConnection connection) {
+        this.connection = connection;
+    }
+    
     public Dispatch(String endpointUrl, String soapAction, String username,
             String password) throws IOException {
-            connection = (HttpConnection) Connector.open(endpointUrl,
+            HttpConnection con = (HttpConnection) Connector.open(endpointUrl,
                     Connector.READ_WRITE, true);
             if (soapAction == null) {
                 // WS-I BP 1.0 R2745
@@ -47,12 +36,12 @@
             }
             // WS-I BP 1.0 R2744
             soapAction = "\"" + soapAction + "\"";
-            connection.setRequestProperty("SOAPAction", soapAction);
-            connection.setRequestProperty("Content-Type", "text/xml");
+            con.setRequestProperty("SOAPAction", soapAction);
+            con.setRequestProperty("Content-Type", "text/xml");
             // connection.setRequestProperty("Content-Type",
             // "application/fastinfoset");
 
-            connection.setRequestProperty("User-Agent", "mirae/1.0");
+            con.setRequestProperty("User-Agent", "mirae/1.0");
             if (username != null) {
                 StringBuffer tmpBuf = new StringBuffer();
 
@@ -60,14 +49,22 @@
                         (password == null) ? "" : password);
                 String value = " Basic "
                         + Base64.encode(tmpBuf.toString().getBytes());
-                connection.setRequestProperty(
+                con.setRequestProperty(
                         OperationStax.HEADER_AUTHORIZATION, value);
             }
 
-            connection.setRequestMethod(HttpConnection.POST);
+            con.setRequestMethod(HttpConnection.POST);
+            connection = con;
     }
 
+    public XMLStreamWriter getResponseWriter() throws XMLStreamException, IOException {
+        return getRequestWriter();
+    }
+    
     public XMLStreamWriter getRequestWriter() throws XMLStreamException, IOException {
+        // XMLOutputFactory outputFactory = new StAXOutputFactory();
+        // outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
+        // Boolean.TRUE);
         return XMLOutputFactory.newInstance().createXMLStreamWriter(connection.openOutputStream());
     }
 
@@ -80,6 +77,10 @@
             connection = null;
         }
         
+    }
+    
+    public XMLStreamReader getRequestReader() throws XMLStreamException, IOException {
+        return getResponseReader();
     }
 
     public XMLStreamReader getResponseReader() throws XMLStreamException, IOException {



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