001: /**
002: * Copyright 2003 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.providers.simplewebservice.rpc;
013:
014: import com.sun.portal.providers.simplewebservice.WebServiceDescriptor;
015: import com.sun.portal.providers.simplewebservice.ParameterDescriptor;
016: import com.sun.portal.providers.simplewebservice.util.XList;
017: import com.sun.xml.rpc.encoding.*;
018: import com.sun.xml.rpc.encoding.soap.CollectionSerializer;
019: import com.sun.xml.rpc.encoding.literal.LiteralFragmentSerializer;
020: import com.sun.xml.rpc.encoding.literal.LiteralSimpleTypeSerializer;
021: import com.sun.xml.rpc.encoding.literal.LiteralArraySerializer;
022: import com.sun.xml.rpc.wsdl.document.schema.SchemaConstants;
023: import com.sun.xml.rpc.util.StructMap;
024: import com.sun.xml.rpc.soap.SOAPVersion;
025:
026: import javax.xml.rpc.Call;
027: import javax.xml.rpc.Service;
028: import javax.xml.rpc.ServiceException;
029: import javax.xml.rpc.JAXRPCException;
030: import javax.xml.rpc.encoding.TypeMappingRegistry;
031: import javax.xml.rpc.encoding.TypeMapping;
032: import javax.xml.rpc.encoding.SerializerFactory;
033: import javax.xml.rpc.encoding.DeserializerFactory;
034: import javax.xml.namespace.QName;
035: import javax.xml.soap.SOAPElement;
036: import java.util.Iterator;
037: import java.util.ArrayList;
038:
039: public class RPCCallFactoryImpl implements SWSCallFactory {
040: private static RPCCallFactoryImpl ourInstance;
041: private static final String ENCODING_STYLE_URI_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
042:
043: private static final int COMPLEX_TYPE_SERIALIZER = 1;
044: private static final int COMPLEX_ARRAY_TYPE_SERIALIZER = 2;
045:
046: public synchronized static RPCCallFactoryImpl getInstance() {
047: if (ourInstance == null) {
048: ourInstance = new RPCCallFactoryImpl();
049: }
050: return ourInstance;
051: }
052:
053: private RPCCallFactoryImpl() {
054: }
055:
056: public Call createCallObject(Service service,
057: WebServiceDescriptor descriptor) throws ServiceException {
058: RPCCallHandler handler = new RPCCallHandler();
059:
060: Call callObj = handler.createCall(service, descriptor);
061:
062: setCallProperties(callObj, descriptor);
063:
064: return callObj;
065: }
066:
067: /*
068: * Sets the properties on the given Call object. The properties set are
069: * the binding style, the soap action and soap action URI, the end-point URL
070: * and the encoding style for input and output.
071: */
072: private void setCallProperties(Call call,
073: WebServiceDescriptor webServiceDescriptor)
074: throws JAXRPCException {
075:
076: // Set the end point address
077: call.setTargetEndpointAddress(webServiceDescriptor
078: .getEndPointURL());
079:
080: // Set the binding style - rpc or document. Default to rpc.
081: String soapBindingStyle = webServiceDescriptor
082: .getSOAPBindingStyle();
083:
084: if (soapBindingStyle == null) {
085: soapBindingStyle = "rpc";
086: }
087: call.setProperty(Call.OPERATION_STYLE_PROPERTY,
088: soapBindingStyle);
089:
090: // Set the SOAP action value. Default to empty string.
091: String soapAction = webServiceDescriptor.getSOAPAction();
092: if (soapAction == null) {
093: soapAction = "";
094: }
095: call.setProperty(Call.SOAPACTION_USE_PROPERTY,
096: new Boolean(true));
097: call.setProperty(Call.SOAPACTION_URI_PROPERTY, soapAction);
098:
099: // Set the encoding style to that of the input.
100: // The assumption is that encoding would be same for input/output.
101: String soapEncodingURI = webServiceDescriptor
102: .getInputEncodingStyleURI();
103: //Trying out if we caninvoke doc/lit service this way
104: if (soapEncodingURI != null /*&& !soapEncodingURI.equals("")*/) {
105: call.setProperty(ENCODING_STYLE_URI_PROPERTY,
106: webServiceDescriptor.getInputEncodingStyleURI());
107: }
108: }
109:
110: /*
111: * Handles the creation of the javax.xml.rpc.Call object and the setting
112: * of the serializers and the deserializers of the Call parameters.
113: */
114:
115: }
|