// This class was generated by the JAXRPC SI, do not edit.
// Contents subject to change without notice.
// JAX-RPC Standard Implementation (1.1.2, build R23)
// Generated source version: 1.1.2

package org.tempuri.sample;

import com.sun.xml.rpc.server.http.MessageContextProperties;
import com.sun.xml.rpc.streaming.*;
import com.sun.xml.rpc.encoding.*;
import com.sun.xml.rpc.encoding.soap.SOAPConstants;
import com.sun.xml.rpc.encoding.soap.SOAP12Constants;
import com.sun.xml.rpc.encoding.literal.*;
import com.sun.xml.rpc.soap.streaming.*;
import com.sun.xml.rpc.soap.message.*;
import com.sun.xml.rpc.soap.SOAPVersion;
import com.sun.xml.rpc.soap.SOAPEncodingConstants;
import com.sun.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.sun.xml.rpc.client.SenderException;
import com.sun.xml.rpc.client.*;
import com.sun.xml.rpc.client.http.*;
import javax.xml.rpc.handler.*;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.soap.SOAPFaultException;

public class PresidentialElectionResults2004PortType_Stub
    extends com.sun.xml.rpc.client.StubBase
    implements org.tempuri.sample.PresidentialElectionResults2004PortType {
    
    
    
    /*
     *  public constructor
     */
    public PresidentialElectionResults2004PortType_Stub(HandlerChain handlerChain) {
        super(handlerChain);
        _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://dietrich.ganx4.com/president/server.php");
    }
    
    
    /*
     *  implementation of whoisgoingtobepresident
     */
    public org.tempuri.sample.Results whoisgoingtobepresident()
        throws java.rmi.RemoteException {
        
        try {
            
            StreamingSenderState _state = _start(_handlerChain);
            
            InternalSOAPMessage _request = _state.getRequest();
            _request.setOperationCode(whoisgoingtobepresident_OPCODE);
            org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct _myPresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct =
                new org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct();
            
            
            SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_whoisgoingtobepresident_whoisgoingtobepresident_QNAME);
            _bodyBlock.setValue(_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct);
            _bodyBlock.setSerializer(ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct_SOAPSerializer);
            _request.setBody(_bodyBlock);
            
            _state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "http://dietrich.ganx4.com/president/server.php/whoisgoingtobepresident");
            
            _send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
            
            org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct _myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct = null;
            Object _responseObj = _state.getResponse().getBody().getValue();
            if (_responseObj instanceof SOAPDeserializationState) {
                _myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct =
                    (org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct)((SOAPDeserializationState)_responseObj).getInstance();
            } else {
                _myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct =
                    (org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct)_responseObj;
            }
            
            return _myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct.get_return();
        } 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 whoisgoingtobepresident_OPCODE:
                _deserialize_whoisgoingtobepresident(bodyReader, deserializationContext, state);
                break;
            default:
                throw new SenderException("sender.response.unrecognizedOperation", Integer.toString(opcode));
        }
    }
    
    
    
    /*
     * This method deserializes the body of the whoisgoingtobepresident operation.
     */
    private void _deserialize_whoisgoingtobepresident(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState state) throws Exception {
        Object myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStructObj =
            ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct_SOAPSerializer.deserialize(ns1_whoisgoingtobepresident_whoisgoingtobepresidentResponse_QNAME,
                bodyReader, deserializationContext);
        
        SOAPBlockInfo bodyBlock = new SOAPBlockInfo(ns1_whoisgoingtobepresident_whoisgoingtobepresidentResponse_QNAME);
        bodyBlock.setValue(myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStructObj);
        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;
    }
    
    
    protected void _preHandlingHook(StreamingSenderState state) throws Exception {
        super._preHandlingHook(state);
    }
    
    
    protected boolean _preRequestSendingHook(StreamingSenderState state) throws Exception {
        boolean bool = false;
        bool = super._preRequestSendingHook(state);
        return bool;
    }
    
    public void _initialize(InternalTypeMappingRegistry registry) throws Exception {
        super._initialize(registry);
        ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct.class, ns1_whoisgoingtobepresidentResponse_TYPE_QNAME);
        ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, org.tempuri.sample.PresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct.class, ns1_whoisgoingtobepresident_TYPE_QNAME);
    }
    
    private static final QName _portName = new QName("http://dietrich.ganx4.com/", "Presidential Election Results 2004Port");
    private static final int whoisgoingtobepresident_OPCODE = 0;
    private static final QName ns1_whoisgoingtobepresident_whoisgoingtobepresident_QNAME = new QName("http://dietrich.ganx4.com/", "whoisgoingtobepresident");
    private static final QName ns1_whoisgoingtobepresident_TYPE_QNAME = new QName("http://dietrich.ganx4.com/", "whoisgoingtobepresident");
    private CombinedSerializer ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_RequestStruct_SOAPSerializer;
    private static final QName ns1_whoisgoingtobepresident_whoisgoingtobepresidentResponse_QNAME = new QName("http://dietrich.ganx4.com/", "whoisgoingtobepresidentResponse");
    private static final QName ns1_whoisgoingtobepresidentResponse_TYPE_QNAME = new QName("http://dietrich.ganx4.com/", "whoisgoingtobepresidentResponse");
    private CombinedSerializer ns1_myPresidentialElectionResults2004PortType_whoisgoingtobepresident_ResponseStruct_SOAPSerializer;
    private static final String[] myNamespace_declarations =
                                        new String[] {
                                            "ns0", "http://dietrich.ganx4.com/"
                                        };
    
    private static final QName[] understoodHeaderNames = new QName[] {  };
}
