use of javax.wsdl.Binding in project cxf by apache.
the class WSIBPValidator method checkBinding.
public boolean checkBinding() {
for (PortType portType : wsdlHelper.getPortTypes(def)) {
Iterator<?> ite = portType.getOperations().iterator();
while (ite.hasNext()) {
Operation operation = (Operation) ite.next();
if (isOverloading(operation.getName())) {
continue;
}
BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
if (bop == null) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2718") + "A wsdl:binding in a DESCRIPTION MUST have the same set of " + "wsdl:operations as the wsdl:portType to which it refers. " + operation.getName() + " not found in wsdl:binding.");
return false;
}
Binding binding = wsdlHelper.getBinding(bop, def);
String bindingStyle = binding != null ? SOAPBindingUtil.getBindingStyle(binding) : "";
String style = StringUtils.isEmpty(SOAPBindingUtil.getSOAPOperationStyle(bop)) ? bindingStyle : SOAPBindingUtil.getSOAPOperationStyle(bop);
if ("DOCUMENT".equalsIgnoreCase(style) || StringUtils.isEmpty(style)) {
boolean passed = checkR2201Input(operation, bop) && checkR2201Output(operation, bop) && checkR2209(operation, bop) && checkR2716(bop);
if (!passed) {
return false;
}
} else {
if (!checkR2717AndR2726(bop)) {
return false;
}
}
}
}
return true;
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSIBPValidator method checkR2205.
// TODO: Should also check SoapHeader/SoapHeaderFault
public boolean checkR2205() {
Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
for (Binding binding : bindings) {
if (!SOAPBindingUtil.isSOAPBinding(binding)) {
System.err.println("WSIBP Validator found <" + binding.getQName() + "> is NOT a SOAP binding");
continue;
}
if (binding.getPortType() == null) {
// will error later
continue;
}
for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
Operation operation = (Operation) ite2.next();
Collection<Fault> faults = CastUtils.cast(operation.getFaults().values());
if (CollectionUtils.isEmpty(faults)) {
continue;
}
for (Fault fault : faults) {
Message message = fault.getMessage();
Collection<Part> parts = CastUtils.cast(message.getParts().values());
for (Part part : parts) {
if (part.getElementName() == null) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message " + message.getQName() + ", part " + part.getName() + " must specify a 'element' attribute");
return false;
}
}
}
}
}
return true;
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLRefValidator method collectValidationPointsForBindings.
private void collectValidationPointsForBindings() throws Exception {
Map<QName, XNode> vBindingNodes = new HashMap<>();
for (Service service : services.values()) {
vBindingNodes.putAll(getBindings(service));
}
for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) {
QName bName = entry.getKey();
Binding binding = this.definition.getBinding(bName);
if (binding == null) {
LOG.log(Level.SEVERE, bName.toString() + " is not correct, please check that the correct namespace is being used");
throw new Exception(bName.toString() + " is not correct, please check that the correct namespace is being used");
}
XNode vBindingNode = getXNode(binding);
vBindingNode.setFailurePoint(entry.getValue());
vNodes.add(vBindingNode);
if (binding.getPortType() == null) {
continue;
}
portTypeRefNames.add(binding.getPortType().getQName());
XNode vPortTypeNode = getXNode(binding.getPortType());
vPortTypeNode.setFailurePoint(vBindingNode);
vNodes.add(vPortTypeNode);
Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations());
for (BindingOperation bop : bops) {
XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName());
XNode vBopNode = getOperationXNode(vBindingNode, bop.getName());
vOpNode.setFailurePoint(vBopNode);
vNodes.add(vOpNode);
if (bop.getBindingInput() != null) {
String inName = bop.getBindingInput().getName();
if (!StringUtils.isEmpty(inName)) {
XNode vInputNode = getInputXNode(vOpNode, inName);
vInputNode.setFailurePoint(getInputXNode(vBopNode, inName));
vNodes.add(vInputNode);
}
}
if (bop.getBindingOutput() != null) {
String outName = bop.getBindingOutput().getName();
if (!StringUtils.isEmpty(outName)) {
XNode vOutputNode = getOutputXNode(vOpNode, outName);
vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName));
vNodes.add(vOutputNode);
}
}
for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext(); ) {
String faultName = (String) iter1.next();
XNode vFaultNode = getFaultXNode(vOpNode, faultName);
vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName));
vNodes.add(vFaultNode);
}
}
}
}
use of javax.wsdl.Binding in project cxf by apache.
the class JAXWSDefinitionBuilder method isRPCEncoded.
private boolean isRPCEncoded(Definition def) {
Iterator<?> ite1 = def.getBindings().values().iterator();
while (ite1.hasNext()) {
Binding binding = (Binding) ite1.next();
String bindingStyle = SOAPBindingUtil.getBindingStyle(binding);
Iterator<?> ite2 = binding.getBindingOperations().iterator();
while (ite2.hasNext()) {
BindingOperation bop = (BindingOperation) ite2.next();
String bopStyle = SOAPBindingUtil.getSOAPOperationStyle(bop);
String outputUse = "";
if (SOAPBindingUtil.getBindingOutputSOAPBody(bop) != null) {
outputUse = SOAPBindingUtil.getBindingOutputSOAPBody(bop).getUse();
}
String inputUse = "";
if (SOAPBindingUtil.getBindingInputSOAPBody(bop) != null) {
inputUse = SOAPBindingUtil.getBindingInputSOAPBody(bop).getUse();
}
if ((SOAPBinding.Style.RPC.name().equalsIgnoreCase(bindingStyle) || SOAPBinding.Style.RPC.name().equalsIgnoreCase(bopStyle)) && (SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(inputUse) || SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(outputUse))) {
return true;
}
}
}
return false;
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLToSoapProcessorTest method testDocLitWithFault.
@Test
public void testDocLitWithFault() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world_doc_lit.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_doc_lit-soapbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_Binding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:binding Missed!");
}
BindingOperation bo = binding.getBindingOperation("pingMe", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"pingMe\"> Missed!");
}
found = false;
for (Object obj : bo.getExtensibilityElements()) {
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:operation Missed!");
}
BindingFault fault = bo.getBindingFault("pingMeFault");
if (fault == null) {
fail("Element <wsdl:fault name=\"pingMeFault\"> Missed!");
}
found = false;
for (Object obj : fault.getExtensibilityElements()) {
if (SOAPBindingUtil.isSOAPFault(obj)) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:fault Missed!");
}
List<SoapFault> faults = SOAPBindingUtil.getBindingOperationSoapFaults(bo);
assertEquals(1, faults.size());
assertEquals("pingMeFault", faults.get(0).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
Aggregations