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 du...@apache.org on 2007/04/17 13:14:46 UTC

svn commit: r529567 - /webservices/axis/trunk/java/src/org/apache/axis/client/Call.java

Author: dug
Date: Tue Apr 17 04:14:45 2007
New Revision: 529567

URL: http://svn.apache.org/viewvc?view=rev&rev=529567
Log:
Make setting the SOAPActionURI set the wsa:Action too.
For inokve(SOAPBodyElement[]) make sure we normalize the result so that
the elements can be stand-alone and used by the application w/o things
like missing prefixes.
Remove some unneeded "throws Exceptions" on some methods

Modified:
    webservices/axis/trunk/java/src/org/apache/axis/client/Call.java

Modified: webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/client/Call.java?view=diff&rev=529567&r1=529566&r2=529567
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/client/Call.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/client/Call.java Tue Apr 17 04:14:45 2007
@@ -358,6 +358,16 @@
         setTargetEndpointAddress(url);
     }
 
+    /**
+     * Build a call from an EPR.
+     *
+     * @param epr the target endpoint EPR
+     */
+    public Call(EndpointReference epr) {
+        this(new Service());
+        setTo(epr);
+    }
+
     ////////////////////////////
     //
     // Properties and the shortcuts for common ones.
@@ -766,6 +776,8 @@
     public void setSOAPActionURI(String SOAPActionURI) {
         useSOAPAction = true;
         this.SOAPActionURI = SOAPActionURI;
+        if (this.getAction() != null && !SOAPActionURI.equals(this.getAction()))
+            this.setAction( SOAPActionURI );
     } // setSOAPActionURI
 
     /**
@@ -1798,14 +1810,14 @@
         for ( i = 0 ; params != null && i < params.length ; i++ )
             if ( !(params[i] instanceof SOAPBodyElement) ) break ;
 
-        if ( params != null && params.length > 0 && i == params.length ) {
+        if ( params == null || (params.length > 0 && i == params.length) ) {
             /* ok, we're doing Messaging, so build up the message */
             /******************************************************/
             isMsg = true ;
             env = new SOAPEnvelope(msgContext.getSOAPConstants(),
                                    msgContext.getSchemaVersion());
 
-            for (i = 0; i < params.length; i++) {
+            for (i = 0; params != null && i < params.length; i++) {
                 env.addBodyElement((SOAPBodyElement) params[i]);
             }
 
@@ -1824,7 +1836,27 @@
             }
 
             env = msg.getSOAPEnvelope();
-            return( env.getBodyElements() );
+
+            Vector res = env.getBodyElements();
+            if ( res == null || res.size() == 0 || 
+                 (res.get(0) instanceof RPCElement)) return res ;
+
+            // Copy the elements into a new Vector so that we resolve all
+            // of the prefixes
+            // For SOAPBodyElements, reserialize them so that they are
+            // stand-alone Elements.
+            Vector res1 = new Vector();
+            for (i = 0 ; i < res.size() ; i++ ) {
+              SOAPBodyElement sbe = (SOAPBodyElement) res.get(i);
+              java.io.PrintStream err = System.err ;
+              try {
+                sbe = new SOAPBodyElement( sbe.getAsDOM() );
+              }catch(Exception exp) {
+                throw new java.rmi.RemoteException( exp.toString());
+              }
+              res1.add( sbe );
+            }
+            return res1 ;
         }
 
 
@@ -3063,10 +3095,11 @@
      * Note: this does not set the transport URL.  As of now they are
      * treated as two independent entities.
      */
-    public void setTo(EndpointReference epr) throws Exception {
+    public void setTo(EndpointReference epr) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setTo( epr );
+      setTargetEndpointAddress( epr.getAddress() );
     }
 
     /**
@@ -3077,10 +3110,11 @@
      * Note: this does not set the transport URL.  As of now they are
      * treated as two independent entities.
      */
-    public void setTo(String url) throws Exception {
+    public void setTo(String url) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setTo( EndpointReference.fromLocation( url ) );
+      setTargetEndpointAddress( url );
     }
 
     /**
@@ -3092,11 +3126,30 @@
     }
 
     /**
+     * Sets the WS-Addressing wsa:Action
+     */
+    public void setAction(String action) {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setAction( action );
+      if ( !action.equals(getSOAPActionURI()) )
+        setSOAPActionURI( action );
+    }
+
+    /**
+     * Gets the WS-Addressing wsa:Action
+     */
+    public String getAction() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getAction();
+    }
+
+    /**
      * Sets the WS-Addressing wsa:From value 
      *
      * @param epr The epr to use for the wsa:From
      */
-    public void setFrom(EndpointReference epr) throws Exception {
+    public void setFrom(EndpointReference epr) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setFrom( epr );
@@ -3107,7 +3160,7 @@
      *
      * @param epr The url to use for the wsa:From
      */
-    public void setFrom(String url) throws Exception {
+    public void setFrom(String url) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setFrom( EndpointReference.fromLocation( url ) );
@@ -3128,7 +3181,7 @@
      * 
      * @param epr The epr to use for the wsa:ReplyTo
      */
-    public void setReplyTo(EndpointReference epr) throws Exception {
+    public void setReplyTo(EndpointReference epr) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setReplyTo( epr );
@@ -3139,7 +3192,7 @@
      *
      * @param url The url to use for the wsa:ReplyTo Address field
      */
-    public void setReplyTo(String url) throws Exception {
+    public void setReplyTo(String url) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setReplyTo( EndpointReference.fromLocation( url ) );
@@ -3160,7 +3213,7 @@
      *
      * @param epr he epr to use for the wsa:FaultTo
      */
-    public void setFaultTo(EndpointReference epr) throws Exception {
+    public void setFaultTo(EndpointReference epr) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setFaultTo( epr );
@@ -3171,7 +3224,7 @@
      * 
      * @param url The url to use  for the wsa:FaultTo Address field
      */
-    public void setFaultTo(String url) throws Exception {
+    public void setFaultTo(String url) {
       MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
       if ( mih == null ) mih = new MIHeader( this );
       mih.setFaultTo( EndpointReference.fromLocation( url ) );



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