001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.axis.client;
018    
019    import java.net.URL;
020    import javax.xml.namespace.QName;
021    
022    import org.apache.axis.AxisFault;
023    import org.apache.axis.NoEndPointException;
024    import org.apache.axis.client.Call;
025    import org.apache.axis.client.Service;
026    
027    /**
028     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
029     */
030    public class GenericServiceEndpoint extends org.apache.axis.client.Stub {
031    
032    
033        public GenericServiceEndpoint(QName portQName, Service service, URL location) {
034            this.service = service;
035            cachedEndpoint = location;
036            cachedPortName = portQName;
037    
038        }
039    
040        Call createCall() throws java.rmi.RemoteException {
041            try {
042                org.apache.axis.client.Call _call =
043                        (org.apache.axis.client.Call) service.createCall();
044                if (super.maintainSessionSet) {
045                    _call.setMaintainSession(super.maintainSession);
046                }
047                if (super.cachedUsername != null) {
048                    _call.setUsername(super.cachedUsername);
049                }
050                if (super.cachedPassword != null) {
051                    _call.setPassword(super.cachedPassword);
052                }
053                if (super.cachedEndpoint != null) {
054                    _call.setTargetEndpointAddress(super.cachedEndpoint);
055                }
056                if (super.cachedTimeout != null) {
057                    _call.setTimeout(super.cachedTimeout);
058                }
059                if (super.cachedPortName != null) {
060                    _call.setPortName(super.cachedPortName);
061                }
062                java.util.Enumeration keys = super.cachedProperties.keys();
063                while (keys.hasMoreElements()) {
064                    java.lang.String key = (java.lang.String) keys.nextElement();
065                    _call.setProperty(key, super.cachedProperties.get(key));
066                }
067                // All the type mapping information is registered
068                // when the first call is made.
069                // The type mapping information is actually registered in
070                // the TypeMappingRegistry of the service, which
071                // is the reason why registration is only needed for the first call.
072                //TODO figure out if this can be done during deployment!
073    //            synchronized (this) {
074    //                if (firstCall()) {
075    //                    // must set encoding style before registering serializers
076    //                    //TODO these constants probably need to be parameters of GSE.
077    //                    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
078    ////                    _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
079    //                    //override unsigned long mapping
080    //                    _call.registerTypeMapping(BigInteger.class,
081    //                            Constants.XSD_UNSIGNEDLONG,
082    //                            new SimpleSerializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG),
083    //                            new SimpleDeserializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG));
084    //                    _call.registerTypeMapping(URI.class,
085    //                            Constants.XSD_ANYURI,
086    //                            new SimpleSerializerFactory(URI.class, Constants.XSD_ANYURI),
087    //                            new SimpleDeserializerFactory(URI.class, Constants.XSD_ANYURI));
088    //                    for (Iterator iterator = typeInfo.iterator(); iterator.hasNext();) {
089    //                        TypeInfo info = (TypeInfo) iterator.next();
090    //                        _call.registerTypeMapping(info.getClazz(), info.getqName(), info.getSerFactoryClass(), info.getDeserFactoryClass(), false);
091    //                    }
092    //                }
093    //            }
094                return _call;
095            } catch (java.lang.Throwable t) {
096                throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
097            }
098        }
099    
100        void checkCachedEndpoint() throws NoEndPointException {
101            if (cachedEndpoint == null) {
102                throw new NoEndPointException();
103            }
104        }
105    
106        void setUpCall(Call call) throws AxisFault {
107            setRequestHeaders(call);
108            setAttachments(call);
109        }
110    
111    }