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

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

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 Hello_PortType_Stub
    extends com.nec.webotx.webservice.xml.rpc.client.StubBase
    implements com.nec.webotx.webservice.director.Hello.Hello_PortType {
    
    
    /*
     *  public constructor
     */
    public Hello_PortType_Stub(HandlerChain handlerChain) {
        super(handlerChain);
        _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://localhost/HelloService/Hello");
    }
    
    
    /*
     *  implementation of say_hello_Hello
     */
    public java.lang.String say_hello_Hello(java.lang.String string_1)
        throws java.rmi.RemoteException {
        
        try {
            
            StreamingSenderState _state = _start(_handlerChain);
            
            InternalSOAPMessage _request = _state.getRequest();
            _request.setOperationCode(say_hello_Hello_OPCODE);
            com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_RequestStruct2 _myHello_say_hello_Hello_RequestStruct2 =
                new com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_RequestStruct2();
            
            _myHello_say_hello_Hello_RequestStruct2.setString_1(string_1);
            
            SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_say_hello_Hello_say_hello_Hello_QNAME);
            _bodyBlock.setValue(_myHello_say_hello_Hello_RequestStruct2);
            _bodyBlock.setSerializer(ns1_myHello_say_hello_Hello_RequestStruct2_SOAPSerializer);
            _request.setBody(_bodyBlock);
            
            _state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "");
            
            _send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
            
            com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_ResponseStruct2 _myHello_say_hello_Hello_ResponseStruct2 = null;
            Object _responseObj = _state.getResponse().getBody().getValue();
            if (_responseObj instanceof SOAPDeserializationState) {
                _myHello_say_hello_Hello_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_ResponseStruct2)((SOAPDeserializationState)_responseObj).getInstance();
            } else {
                _myHello_say_hello_Hello_ResponseStruct2 =
                    (com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_ResponseStruct2)_responseObj;
            }
            
            return _myHello_say_hello_Hello_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 say_hello_Hello_OPCODE:
                _deserialize_say_hello_Hello(bodyReader, deserializationContext, state);
                break;
            default:
                throw new SenderException("sender.response.unrecognizedOperation", Integer.toString(opcode));
        }
    }
    
    
    
    /*
     * This method deserializes the body of the say_hello_Hello operation.
     */
    private void _deserialize_say_hello_Hello(XMLReader bodyReader, SOAPDeserializationContext deserializationContext, StreamingSenderState state) throws Exception {
        Object myHello_say_hello_Hello_ResponseStruct2Obj =
            ns1_myHello_say_hello_Hello_ResponseStruct2_SOAPSerializer.deserialize(ns1_say_hello_Hello_say_hello_HelloResponse_QNAME,
                bodyReader, deserializationContext);
        
        SOAPBlockInfo bodyBlock = new SOAPBlockInfo(ns1_say_hello_Hello_say_hello_HelloResponse_QNAME);
        bodyBlock.setValue(myHello_say_hello_Hello_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_myHello_say_hello_Hello_RequestStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_RequestStruct2.class, ns1_say_hello_Hello_TYPE_QNAME);
        ns1_myHello_say_hello_Hello_ResponseStruct2_SOAPSerializer = (CombinedSerializer)registry.getSerializer(SOAPConstants.NS_SOAP_ENCODING, com.nec.webotx.webservice.director.Hello.Hello_say_hello_Hello_ResponseStruct2.class, ns1_say_hello_HelloResponse_TYPE_QNAME);
    }
    
    private static final QName _portName = new QName("http://sample/Hello", "HelloPort");
    private static final int say_hello_Hello_OPCODE = 0;
    private static final QName ns1_say_hello_Hello_say_hello_Hello_QNAME = new QName("http://sample/Hello", "say_hello_Hello");
    private static final QName ns1_say_hello_Hello_TYPE_QNAME = new QName("http://sample/Hello", "say_hello_Hello");
    private CombinedSerializer ns1_myHello_say_hello_Hello_RequestStruct2_SOAPSerializer;
    private static final QName ns1_say_hello_Hello_say_hello_HelloResponse_QNAME = new QName("http://sample/Hello", "say_hello_HelloResponse");
    private static final QName ns1_say_hello_HelloResponse_TYPE_QNAME = new QName("http://sample/Hello", "say_hello_HelloResponse");
    private CombinedSerializer ns1_myHello_say_hello_Hello_ResponseStruct2_SOAPSerializer;
    private static final String[] myNamespace_declarations =
                                        new String[] {
                                            "ns0", "http://sample/Hello"
                                        };
    
    private static final QName[] understoodHeaderNames = new QName[] {  };
}
