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

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

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 Service1_PortType_Stub
    extends com.nec.webotx.webservice.xml.rpc.client.StubBase
    implements com.nec.webotx.webservice.director.service1.Service1_PortType {
    
    
    /*
     *  public constructor
     */
    public Service1_PortType_Stub(HandlerChain handlerChain) {
        super(handlerChain);
        _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://localhost/sample1_service/service1");
    }
    
    
    /*
     *  implementation of method1_Sample1
     */
    public java.lang.String method1_Sample1(java.lang.String string_1)
        throws java.rmi.RemoteException {
        
        try {
            
            StreamingSenderState _state = _start(_handlerChain);
            
            InternalSOAPMessage _request = _state.getRequest();
            _request.setOperationCode(method1_Sample1_OPCODE);
            com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_RequestStruct2 _myService1_method1_Sample1_RequestStruct2 =
                new com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_RequestStruct2();
            
            _myService1_method1_Sample1_RequestStruct2.setString_1(string_1);
            
            SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_method1_Sample1_method1_Sample1_QNAME);
            _bodyBlock.setValue(_myService1_method1_Sample1_RequestStruct2);
            _bodyBlock.setSerializer(ns1_myService1_method1_Sample1_RequestStruct2_SOAPSerializer);
            _request.setBody(_bodyBlock);
            
            _state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "");
            
            _send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
            
            com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_ResponseStruct2 _myService1_method1_Sample1_ResponseStruct2 = null;
            Object _responseObj = _state.getResponse().getBody().getValue();
            if (_responseObj instanceof SOAPDeserializationState) {
                _myService1_method1_Sample1_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_ResponseStruct2)((SOAPDeserializationState)_responseObj).getInstance();
            } else {
                _myService1_method1_Sample1_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_ResponseStruct2)_responseObj;
            }
            
            return _myService1_method1_Sample1_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 method1_Sample1_OPCODE:
                _deserialize_method1_Sample1(bodyReader, deserializationContext, state);
                break;
            default:
                throw new SenderException("sender.response.unrecognizedOperation", Integer.toString(opcode));
        }
    }
    
    
    
    /*
     * This method deserializes the body of the method1_Sample1 operation.
     */
    private void _deserialize_method1_Sample1(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState state) throws Exception {
        Object myService1_method1_Sample1_ResponseStruct2Obj =
            ns1_myService1_method1_Sample1_ResponseStruct2_SOAPSerializer.deserialize(ns1_method1_Sample1_method1_Sample1Response_QNAME,
                bodyReader, deserializationContext);
        
        SOAPBlockInfo bodyBlock = new SOAPBlockInfo(ns1_method1_Sample1_method1_Sample1Response_QNAME);
        bodyBlock.setValue(myService1_method1_Sample1_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_myService1_method1_Sample1_ResponseStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_ResponseStruct2.class, ns1_method1_Sample1Response_TYPE_QNAME);
        ns1_myService1_method1_Sample1_RequestStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.service1.Service1_method1_Sample1_RequestStruct2.class, ns1_method1_Sample1_TYPE_QNAME);
    }
    
    private static final QName _portName = new QName("http://sample/WebOTX", "Service1Port");
    private static final int method1_Sample1_OPCODE = 0;
    private static final QName ns1_method1_Sample1_method1_Sample1_QNAME = new QName("http://sample/WebOTX", "method1_Sample1");
    private static final QName ns1_method1_Sample1_TYPE_QNAME = new QName("http://sample/WebOTX", "method1_Sample1");
    private CombinedSerializer ns1_myService1_method1_Sample1_RequestStruct2_SOAPSerializer;
    private static final QName ns1_method1_Sample1_method1_Sample1Response_QNAME = new QName("http://sample/WebOTX", "method1_Sample1Response");
    private static final QName ns1_method1_Sample1Response_TYPE_QNAME = new QName("http://sample/WebOTX", "method1_Sample1Response");
    private CombinedSerializer ns1_myService1_method1_Sample1_ResponseStruct2_SOAPSerializer;
    private static final String[] myNamespace_declarations =
                                        new String[] {
                                            "ns0", "http://sample/WebOTX"
                                        };
    
    private static final QName[] understoodHeaderNames = new QName[] {  };
}
