Java 怎么从操作的soap:operation扩展性元素中获取soap-action-uri

2019年7月25日22:40:56Java 怎么从操作的soap:operation扩展性元素中获取soap-action-uri已关闭评论 821 1356字阅读4分31秒

1.简介

Java 怎么从操作的soap:operation扩展性元素中获取soap-action-uri?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

 
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.BindingOutput;
import javax.wsdl.Port;
import javax.wsdl.extensions.ElementExtensible;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPHeader;
import javax.wsdl.extensions.soap.SOAPOperation;

public class Main{
    private static final String SOAP_OPERATION_ELEMENT_NAME = "operation";
    
    protected static String getSOAPAction(BindingOperation operation) {
        ExtensibilityElement e = findExtensibilityElement(operation,
                SOAP_OPERATION_ELEMENT_NAME);
        if (e != null) {
            return ((SOAPOperation) e).getSoapActionURI();
        }
        return null;
    }
    
    @SuppressWarnings("unchecked")
    protected static ExtensibilityElement findExtensibilityElement(
            ElementExtensible extensibleElement, String elementType) {

        List<ExtensibilityElement> extensibilityElements = extensibleElement
                .getExtensibilityElements();
        if (extensibilityElements != null) {
            for (ExtensibilityElement element : extensibilityElements) {
                if (element.getElementType().getLocalPart()
                        .equalsIgnoreCase(elementType)) {
                    return element;
                }
            }
        }
        return null;
    }
}

 
继续阅读
编程十万个怎么办