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

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

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 Service2_PortType_Stub
    extends com.nec.webotx.webservice.xml.rpc.client.StubBase
    implements com.nec.webotx.webservice.director.service2.Service2_PortType {
    
    
    /*
     *  public constructor
     */
    public Service2_PortType_Stub(HandlerChain handlerChain) {
        super(handlerChain);
        _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://localhost/sample2_service/service2");
    }
    
    
    /*
     *  implementation of method2_Sample2
     */
    public java.lang.String method2_Sample2(java.lang.String string_1)
        throws java.rmi.RemoteException {
        
        try {
            
            StreamingSenderState _state = _start(_handlerChain);
            
            InternalSOAPMessage _request = _state.getRequest();
            _request.setOperationCode(method2_Sample2_OPCODE);
            com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_RequestStruct2 _myService2_method2_Sample2_RequestStruct2 =
                new com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_RequestStruct2();
            
            _myService2_method2_Sample2_RequestStruct2.setString_1(string_1);
            
            SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_method2_Sample2_method2_Sample2_QNAME);
            _bodyBlock.setValue(_myService2_method2_Sample2_RequestStruct2);
            _bodyBlock.setSerializer(ns1_myService2_method2_Sample2_RequestStruct2_SOAPSerializer);
            _request.setBody(_bodyBlock);
            
            _state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "");
            
            _send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
            
            com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_ResponseStruct2 _myService2_method2_Sample2_ResponseStruct2 = null;
            Object _responseObj = _state.getResponse().getBody().getValue();
            if (_responseObj instanceof SOAPDeserializationState) {
                _myService2_method2_Sample2_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_ResponseStruct2)((SOAPDeserializationState)_responseObj).getInstance();
            } else {
                _myService2_method2_Sample2_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_ResponseStruct2)_responseObj;
            }
            
            return _myService2_method2_Sample2_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 method2_Sample2_OPCODE:
                _deserialize_method2_Sample2(bodyReader, deserializationContext, state);
                break;
            default:
                throw new SenderException("sender.response.unrecognizedOperation", Integer.toString(opcode));
        }
    }
    
    
    
    /*
     * This method deserializes the body of the method2_Sample2 operation.
     */
    private void _deserialize_method2_Sample2(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState state) throws Exception {
        Object myService2_method2_Sample2_ResponseStruct2Obj =
            ns1_myService2_method2_Sample2_ResponseStruct2_SOAPSerializer.deserialize(ns1_method2_Sample2_method2_Sample2Response_QNAME,
                bodyReader, deserializationContext);
        
        SOAPBlockInfo bodyBlock = new SOAPBlockInfo(ns1_method2_Sample2_method2_Sample2Response_QNAME);
        bodyBlock.setValue(myService2_method2_Sample2_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_myService2_method2_Sample2_RequestStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_RequestStruct2.class, ns1_method2_Sample2_TYPE_QNAME);
        ns1_myService2_method2_Sample2_ResponseStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.service2.Service2_method2_Sample2_ResponseStruct2.class, ns1_method2_Sample2Response_TYPE_QNAME);
    }
    
    private static final QName _portName = new QName("http://sample/WebOTX", "Service2Port");
    private static final int method2_Sample2_OPCODE = 0;
    private static final QName ns1_method2_Sample2_method2_Sample2_QNAME = new QName("http://sample/WebOTX", "method2_Sample2");
    private static final QName ns1_method2_Sample2_TYPE_QNAME = new QName("http://sample/WebOTX", "method2_Sample2");
    private CombinedSerializer ns1_myService2_method2_Sample2_RequestStruct2_SOAPSerializer;
    private static final QName ns1_method2_Sample2_method2_Sample2Response_QNAME = new QName("http://sample/WebOTX", "method2_Sample2Response");
    private static final QName ns1_method2_Sample2Response_TYPE_QNAME = new QName("http://sample/WebOTX", "method2_Sample2Response");
    private CombinedSerializer ns1_myService2_method2_Sample2_ResponseStruct2_SOAPSerializer;
    private static final String[] myNamespace_declarations =
                                        new String[] {
                                            "ns0", "http://sample/WebOTX"
                                        };
    
    private static final QName[] understoodHeaderNames = new QName[] {  };
}
