您需要获取与SOAPOperation对应的ExtensibilityElement并从那里提取SOAPAction.
让我们从TempConvert Web Service开始以一个简单的WSDL为例,从CelsiusToFahrenheit操作中提取SOAP动作;我要跟这个部分:
以下代码打印CelsiusToFahrenheit操作的SOAP操作的值:
WSDLFactory factory = WSDLFactory.newInstance();
WSDLReader reader = factory.newWSDLReader();
Definition definition = reader.readWSDL("http://www.w3schools.com/webservices/tempconvert.asmx?wsdl");
Binding binding = definition.getBinding(new QName("http://tempuri.org/", "TempConvertSoap"));
BindingOperation operation = binding.getBindingOperation("CelsiusToFahrenheit", null, null);
List extensions = operation.getExtensibilityElements();
if (extensions != null) {
for (int i = 0; i < extensions.size(); i++) {
ExtensibilityElement extElement = (ExtensibilityElement) extensions.get(i);
// ....
if (extElement instanceof SOAPOperation) {
SOAPOperation soapOp = (SOAPOperation) extElement;
System.out.println(soapOp.getSoapActionURI());
}
// ....
}
}
输出是这样的:
http://tempuri.org/CelsiusToFahrenheit