/**
 * Do not edit.
 *
 * This file was auto-generated
 * by the Web Service Director Eclipse Plugin Edition.
 */

package com.nec.webotx.webservice.director.aggregator;

import com.nec.webotx.webservice.xml.rpc.server.http.MessageContextProperties;
import com.nec.webotx.webservice.xml.rpc.streaming.*;
import com.nec.webotx.webservice.xml.rpc.encoding.*;
import com.nec.webotx.webservice.xml.rpc.encoding.soap.SOAPConstants;
import com.nec.webotx.webservice.xml.rpc.encoding.soap.SOAP12Constants;
import com.nec.webotx.webservice.xml.rpc.encoding.literal.*;
import com.nec.webotx.webservice.xml.rpc.soap.streaming.*;
import com.nec.webotx.webservice.xml.rpc.soap.message.*;
import com.nec.webotx.webservice.xml.rpc.soap.SOAPVersion;
import com.nec.webotx.webservice.xml.rpc.soap.SOAPEncodingConstants;
import com.nec.webotx.webservice.xml.rpc.wsdl.document.schema.SchemaConstants;
import javax.xml.namespace.QName;
import java.rmi.RemoteException;
import java.util.Iterator;
import java.lang.reflect.*;
import java.lang.Class;
import com.nec.webotx.webservice.xml.rpc.client.SenderException;
import com.nec.webotx.webservice.xml.rpc.client.*;
import com.nec.webotx.webservice.xml.rpc.client.http.*;
import javax.xml.rpc.handler.*;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.soap.SOAPFaultException;

public class Aggregator_PortType_Stub
    extends com.nec.webotx.webservice.xml.rpc.client.StubBase
    implements com.nec.webotx.webservice.director.aggregator.Aggregator_PortType {
    
    
    /*
     *  public constructor
     */
    public Aggregator_PortType_Stub(HandlerChain handlerChain) {
        super(handlerChain);
        _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://localhost/aggregation_service/aggregator");
    }
    
    
    /*
     *  implementation of sampleAggregation_Aggregation
     */
    public com.nec.webotx.webservice.sample.Info sampleAggregation_Aggregation(java.lang.String string_1, java.lang.String string_2, java.lang.String string_3, java.lang.String string_4)
        throws java.rmi.RemoteException {
        
        try {
            
            StreamingSenderState _state = _start(_handlerChain);
            
            InternalSOAPMessage _request = _state.getRequest();
            _request.setOperationCode(sampleAggregation_Aggregation_OPCODE);
            com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_RequestStruct2 _myAggregator_sampleAggregation_Aggregation_RequestStruct2 =
                new com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_RequestStruct2();
            
            _myAggregator_sampleAggregation_Aggregation_RequestStruct2.setString_1(string_1);
            _myAggregator_sampleAggregation_Aggregation_RequestStruct2.setString_2(string_2);
            _myAggregator_sampleAggregation_Aggregation_RequestStruct2.setString_3(string_3);
            _myAggregator_sampleAggregation_Aggregation_RequestStruct2.setString_4(string_4);
            
            SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_sampleAggregation_Aggregation_sampleAggregation_Aggregation_QNAME);
            _bodyBlock.setValue(_myAggregator_sampleAggregation_Aggregation_RequestStruct2);
            _bodyBlock.setSerializer(ns1_myAggregator_sampleAggregation_Aggregation_RequestStruct2_SOAPSerializer);
            _request.setBody(_bodyBlock);
            
            _state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "");
            
            _send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
            
            com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_ResponseStruct2 _myAggregator_sampleAggregation_Aggregation_ResponseStruct2 = null;
            Object _responseObj = _state.getResponse().getBody().getValue();
            if (_responseObj instanceof SOAPDeserializationState) {
                _myAggregator_sampleAggregation_Aggregation_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_ResponseStruct2)((SOAPDeserializationState)_responseObj).getInstance();
            } else {
                _myAggregator_sampleAggregation_Aggregation_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_ResponseStruct2)_responseObj;
            }
            
            return _myAggregator_sampleAggregation_Aggregation_ResponseStruct2.getResult();
        } catch (RemoteException e) {
            // let this one through unchanged
            throw e;
        } catch (JAXRPCException e) {
            throw new RemoteException(e.getMessage(), e);
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException)e;
            } else {
                throw new RemoteException(e.getMessage(), e);
            }
        }
    }
    
    
    /*
     *  this method deserializes the request/response structure in the body
     */
    protected void _readFirstBodyElement(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState  state) throws Exception {
        int opcode = state.getRequest().getOperationCode();
        switch (opcode) {
            case sampleAggregation_Aggregation_OPCODE:
                _deserialize_sampleAggregation_Aggregation(bodyReader, deserializationContext, state);
                break;
            default:
                throw new SenderException("sender.response.unrecognizedOperation", Integer.toString(opcode));
        }
    }
    
    
    
    /*
     * This method deserializes the body of the sampleAggregation_Aggregation operation.
     */
    private void _deserialize_sampleAggregation_Aggregation(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState state) throws Exception {
        Object myAggregator_sampleAggregation_Aggregation_ResponseStruct2Obj =
            ns1_myAggregator_sampleAggregation_Aggregation_ResponseStruct2_SOAPSerializer.deserialize(ns1_sampleAggregation_Aggregation_sampleAggregation_AggregationResponse_QNAME,
                bodyReader, deserializationContext);
        
        SOAPBlockInfo bodyBlock = new SOAPBlockInfo(ns1_sampleAggregation_Aggregation_sampleAggregation_AggregationResponse_QNAME);
        bodyBlock.setValue(myAggregator_sampleAggregation_Aggregation_ResponseStruct2Obj);
        state.getResponse().setBody(bodyBlock);
    }
    
    
    
    public String _getDefaultEnvelopeEncodingStyle() {
        return SOAPNamespaceConstants.ENCODING;
    }
    
    public String _getImplicitEnvelopeEncodingStyle() {
        return "";
    }
    
    public String _getEncodingStyle() {
        return SOAPNamespaceConstants.ENCODING;
    }
    
    public void _setEncodingStyle(String encodingStyle) {
        throw new UnsupportedOperationException("cannot set encoding style");
    }
    
    
    
    
    
    /*
     * This method returns an array containing (prefix, nsURI) pairs.
     */
    protected String[] _getNamespaceDeclarations() {
        return myNamespace_declarations;
    }
    
    /*
     * This method returns an array containing the names of the headers we understand.
     */
    public QName[] _getUnderstoodHeaders() {
        return understoodHeaderNames;
    }
    
    public void _initialize(InternalTypeMappingRegistry registry) throws Exception {
        super._initialize(registry);
        ns1_myAggregator_sampleAggregation_Aggregation_ResponseStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_ResponseStruct2.class, ns1_sampleAggregation_AggregationResponse_TYPE_QNAME);
        ns1_myAggregator_sampleAggregation_Aggregation_RequestStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.aggregator.Aggregator_sampleAggregation_Aggregation_RequestStruct2.class, ns1_sampleAggregation_Aggregation_TYPE_QNAME);
    }
    
    private static final QName _portName = new QName("http://sample/WebOTX", "AggregatorPort");
    private static final int sampleAggregation_Aggregation_OPCODE = 0;
    private static final QName ns1_sampleAggregation_Aggregation_sampleAggregation_Aggregation_QNAME = new QName("http://sample/WebOTX", "sampleAggregation_Aggregation");
    private static final QName ns1_sampleAggregation_Aggregation_TYPE_QNAME = new QName("http://sample/WebOTX", "sampleAggregation_Aggregation");
    private CombinedSerializer ns1_myAggregator_sampleAggregation_Aggregation_RequestStruct2_SOAPSerializer;
    private static final QName ns1_sampleAggregation_Aggregation_sampleAggregation_AggregationResponse_QNAME = new QName("http://sample/WebOTX", "sampleAggregation_AggregationResponse");
    private static final QName ns1_sampleAggregation_AggregationResponse_TYPE_QNAME = new QName("http://sample/WebOTX", "sampleAggregation_AggregationResponse");
    private CombinedSerializer ns1_myAggregator_sampleAggregation_Aggregation_ResponseStruct2_SOAPSerializer;
    private static final String[] myNamespace_declarations =
                                        new String[] {
                                            "ns0", "http://sample/WebOTX",
                                            "ns1", "http://sample"
                                        };
    
    private static final QName[] understoodHeaderNames = new QName[] {  };
}
