Package org.apache.ws.util

Source Code of org.apache.ws.util.OperationInfo

/*=============================================================================*
*  Copyright 2004 The Apache Software Foundation
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*=============================================================================*/
package org.apache.ws.util;

import org.apache.commons.lang.StringUtils;

import javax.wsdl.Operation;
import javax.wsdl.Input;
import javax.wsdl.Part;
import javax.wsdl.Output;
import javax.xml.namespace.QName;
import java.util.Map;

/**
* TODO
*
* @author Ian Springer (ian DOT springer AT hp DOT com)
*/
public class OperationInfo
{

    private String m_methodName;
    private String m_methodSig;
    private QName m_requestElemName;


    public OperationInfo( Operation op )
    {
        m_methodName = StringUtils.capitalize( op.getName() );
        Input input = op.getInput();
        String requestClassName;
        if ( input != null )
        {
            Map inputParts = input.getMessage().getParts();
            if ( inputParts.size() != 1 )
            {
                throw new RuntimeException( "Wsdl input element should have exactly one part." );
            }
            Part inputPart = (Part) inputParts.values().iterator().next();
            m_requestElemName = inputPart.getElementName();
            requestClassName = XmlBeanNameUtils.getDocumentElementXmlBeanClassName( m_requestElemName );
        }
        else
        {
            requestClassName = "";
        }
        Output output = op.getOutput();
        String responseClassName;
        if ( output != null )
        {
            Map outputParts = output.getMessage().getParts();
            if ( outputParts.size() != 1 )
            {
                throw new RuntimeException( "Wsdl output element should have exactly one part." );
            }
            Part outputPart = (Part) outputParts.values().iterator().next();
            responseClassName = XmlBeanNameUtils.getDocumentElementXmlBeanClassName( outputPart.getElementName() );
        }
        else
        {
            responseClassName = void.class.getName();
        }
        m_methodSig = responseClassName + " " + m_methodName + "( " + requestClassName + " requestDoc )";
    }

    public String getJavaMethodName()
    {
        return m_methodName;
    }

    public String getJavaMethodSignature()
    {
        return m_methodSig;
    }

    public QName getRequestElementName()
    {
        return m_requestElemName;
    }
}
TOP

Related Classes of org.apache.ws.util.OperationInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.