use of javax.wsdl.Message 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.Message in project cxf by apache.
the class ServiceWSDLBuilderTest method testGreetMeOneWayOperation.
@Test
public void testGreetMeOneWayOperation() throws Exception {
setupWSDL(WSDL_PATH);
PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
Operation greetMeOneWay = portType.getOperation("greetMeOneWay", "greetMeOneWayRequest", null);
assertNotNull(greetMeOneWay);
assertEquals("greetMeOneWay", greetMeOneWay.getName());
Input input = greetMeOneWay.getInput();
assertNotNull(input);
assertEquals("greetMeOneWayRequest", input.getName());
Message message = input.getMessage();
assertNotNull(message);
assertEquals("greetMeOneWayRequest", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(1, message.getParts().size());
assertEquals("in", message.getPart("in").getName());
Output output = greetMeOneWay.getOutput();
assertNull(output);
assertEquals(0, greetMeOneWay.getFaults().size());
}
use of javax.wsdl.Message in project cxf by apache.
the class ServiceWSDLBuilderTest method testPingMeOperation.
@Test
public void testPingMeOperation() throws Exception {
setupWSDL(WSDL_PATH);
PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
Operation pingMe = portType.getOperation("pingMe", "pingMeRequest", "pingMeResponse");
assertNotNull(pingMe);
assertEquals("pingMe", pingMe.getName());
Input input = pingMe.getInput();
assertNotNull(input);
assertEquals("pingMeRequest", input.getName());
Message message = input.getMessage();
assertNotNull(message);
assertEquals("pingMeRequest", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(1, message.getParts().size());
assertEquals("in", message.getPart("in").getName());
Output output = pingMe.getOutput();
assertNotNull(output);
assertEquals("pingMeResponse", output.getName());
message = output.getMessage();
assertNotNull(message);
assertEquals("pingMeResponse", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(message.getParts().size(), 1);
assertEquals("out", message.getPart("out").getName());
assertEquals(1, pingMe.getFaults().size());
Fault fault = pingMe.getFault("pingMeFault");
assertNotNull(fault);
assertEquals("pingMeFault", fault.getName());
message = fault.getMessage();
assertNotNull(message);
assertEquals("pingMeFault", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(1, message.getParts().size());
assertEquals("faultDetail", message.getPart("faultDetail").getName());
assertNull(message.getPart("faultDetail").getTypeName());
}
use of javax.wsdl.Message in project cxf by apache.
the class ServiceWSDLBuilderTest method testNoBodyParts.
@Test
public void testNoBodyParts() throws Exception {
setupWSDL(NO_BODY_PARTS_WSDL_PATH);
QName messageName = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1Request");
Message message = newDef.getMessage(messageName);
Part part = message.getPart("mimeAttachment");
assertNotNull(part.getTypeName());
}
use of javax.wsdl.Message in project cxf by apache.
the class ServiceWSDLBuilder method buildPortTypeOperation.
protected void buildPortTypeOperation(PortType portType, Collection<OperationInfo> operationInfos, final Definition def) {
for (OperationInfo operationInfo : operationInfos) {
Operation operation = null;
try {
operation = operationInfo.getProperty(WSDLServiceBuilder.WSDL_OPERATION, Operation.class);
} catch (ClassCastException e) {
// do nothing
}
if (operation == null) {
operation = def.createOperation();
addDocumentation(operation, operationInfo.getDocumentation());
operation.setUndefined(false);
operation.setName(operationInfo.getName().getLocalPart());
addNamespace(operationInfo.getName().getNamespaceURI(), def);
if (operationInfo.isOneWay()) {
operation.setStyle(OperationType.ONE_WAY);
}
addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo));
Input input = def.createInput();
addDocumentation(input, operationInfo.getInput().getDocumentation());
input.setName(operationInfo.getInputName());
Message message = def.createMessage();
buildMessage(message, operationInfo.getInput(), def);
this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo));
this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput()));
input.setMessage(message);
operation.setInput(input);
operation.setParameterOrdering(operationInfo.getParameterOrdering());
if (operationInfo.getOutput() != null) {
Output output = def.createOutput();
addDocumentation(output, operationInfo.getOutput().getDocumentation());
output.setName(operationInfo.getOutputName());
message = def.createMessage();
buildMessage(message, operationInfo.getOutput(), def);
this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo));
this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput()));
output.setMessage(message);
operation.setOutput(output);
}
// loop to add fault
Collection<FaultInfo> faults = operationInfo.getFaults();
for (FaultInfo faultInfo : faults) {
final Fault fault = def.createFault();
addDocumentation(fault, faultInfo.getDocumentation());
fault.setName(faultInfo.getFaultName().getLocalPart());
message = def.createMessage();
buildMessage(message, faultInfo, def);
this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes());
this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo));
fault.setMessage(message);
operation.addFault(fault);
}
}
portType.addOperation(operation);
}
}
Aggregations