use of javax.wsdl.BindingFault in project cxf by apache.
the class WSDLServiceBuilder method buildBinding.
public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
BindingInfo bi = null;
StringBuilder ns = new StringBuilder(100);
BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
if (factory instanceof WSDLBindingFactory) {
WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
bi = wFactory.createBindingInfo(service, binding, ns.toString());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
}
if (bi == null) {
boolean onlyExtensors = false;
if (factory instanceof AbstractBindingFactory) {
bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
onlyExtensors = true;
} else {
bi = new BindingInfo(service, ns.toString());
}
bi.setName(binding.getQName());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("binding operation name is " + bop.getName());
}
String inName = null;
String outName = null;
if (bop.getBindingInput() != null) {
inName = bop.getBindingInput().getName();
}
if (bop.getBindingOutput() != null) {
outName = bop.getBindingOutput().getName();
}
final BindingOperationInfo bop2;
if (onlyExtensors) {
bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
} else {
bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
if (bop2 != null) {
bi.addOperation(bop2);
}
}
if (bop2 != null) {
copyExtensors(bop2, bop.getExtensibilityElements());
copyExtensionAttributes(bop2, bop);
if (bop.getBindingInput() != null) {
copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
handleHeader(bop2.getInput());
}
if (bop.getBindingOutput() != null) {
copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
handleHeader(bop2.getOutput());
}
for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
}
}
}
}
service.addBinding(bi);
DescriptionInfo d = service.getDescription();
if (null != d) {
d.getDescribed().add(bi);
}
return bi;
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class OperationVisitor method createFaultMessage.
private void createFaultMessage(CorbaTypeImpl corbaType, Operation operation, BindingOperation bindingOperation, QName elementQName) {
String exceptionName = corbaType.getQName().getLocalPart();
Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
if (faultDef == null) {
faultDef = definition;
}
Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
if (faultMsg == null) {
throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
}
// porttype - operation - fault
Fault fault = definition.createFault();
fault.setMessage(faultMsg);
fault.setName(faultMsg.getQName().getLocalPart());
operation.addFault(fault);
// binding - operation - corba:operation - corba:raises
RaisesType raisesType = new RaisesType();
raisesType.setException(new QName(typeMap.getTargetNamespace(), exceptionName));
corbaOperation.getRaises().add(raisesType);
// binding - operation - fault
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(faultMsg.getQName().getLocalPart());
bindingOperation.addBindingFault(bindingFault);
// add the fault element namespace to the definition
String nsURI = elementQName.getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class ServiceWSDLBuilder method buildBindingFault.
protected void buildBindingFault(Definition def, BindingOperation bindingOperation, Collection<BindingFaultInfo> bindingFaultInfos) {
for (BindingFaultInfo bindingFaultInfo : bindingFaultInfos) {
final BindingFault bindingFault = def.createBindingFault();
addDocumentation(bindingFault, bindingFaultInfo.getDocumentation());
bindingFault.setName(bindingFaultInfo.getFaultInfo().getFaultName().getLocalPart());
bindingOperation.addBindingFault(bindingFault);
addExtensibilityAttributes(def, bindingFault, bindingFaultInfo.getExtensionAttributes());
addExtensibilityElements(def, bindingFault, getWSDL11Extensors(bindingFaultInfo));
}
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class WSDLToSoapProcessor method addSoapFaults.
private void addSoapFaults(Operation op, BindingOperation bindingOperation) throws ToolException {
Map<String, Fault> faults = CastUtils.cast(op.getFaults());
for (Fault fault : faults.values()) {
BindingFault bf = wsdlDefinition.createBindingFault();
bf.setName(fault.getName());
setSoapFaultExtElement(bf);
bindingOperation.addBindingFault(bf);
}
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class WSDLToSoapProcessorTest method testAddSoap12Binding.
@Test
public void testAddSoap12Binding() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap12_newbinding.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_SOAP12Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
for (Object obj : binding.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
assertTrue(obj instanceof SOAP12Binding);
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
assertNotNull(soapBinding);
assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
for (Object obj : bo.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
assertTrue(obj instanceof SOAP12Operation);
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
assertNotNull(soapOperation);
assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
}
BindingInput bi = bo.getBindingInput();
for (Object obj : bi.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBody(obj));
assertTrue(obj instanceof SOAP12Body);
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
assertNotNull(soapBody);
assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
}
bo = binding.getBindingOperation("pingMe", null, null);
assertNotNull(bo);
Iterator<?> it = bo.getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Operation);
it = bo.getBindingInput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
it = bo.getBindingOutput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
Map<?, ?> faults = bo.getBindingFaults();
assertTrue(faults != null && faults.size() == 1);
Object bf = faults.get("pingMeFault");
assertNotNull(bf);
assertTrue(bf instanceof BindingFault);
assertEquals("pingMeFault", ((BindingFault) bf).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
Aggregations