use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToSoapProcessor method setSoapFaultExtElement.
private void setSoapFaultExtElement(BindingFault bf) throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
SoapFault soapFault = null;
try {
soapFault = SOAPBindingUtil.createSoapFault(extReg, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapFault.setName(bf.getName());
soapFault.setUse((String) env.get(ToolConstants.CFG_USE));
if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
soapFault.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
}
bf.addExtensibilityElement(soapFault);
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToSoapProcessor method validate.
private void validate() throws ToolException {
if (isBindingExisted()) {
Message msg = new Message("BINDING_ALREADY_EXIST", LOG);
throw new ToolException(msg);
}
if (!isPortTypeExisted()) {
Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
throw new ToolException(msg);
}
if (!nameSpaceCheck()) {
Message msg = new Message("SOAPBINDING_STYLE_NOT_PROVIDED", LOG);
throw new ToolException(msg);
}
if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE))) {
Collection<Operation> ops = CastUtils.cast(portType.getOperations());
for (Operation op : ops) {
Input input = op.getInput();
if (input != null && input.getMessage() != null) {
Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
for (Part part : parts) {
if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
throw new ToolException(msg);
}
}
}
Output output = op.getOutput();
if (output != null && output.getMessage() != null) {
Collection<Part> parts = CastUtils.cast(output.getMessage().getParts().values());
for (Part part : parts) {
if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
throw new ToolException(msg);
}
}
}
}
}
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToSoapProcessor method getSoapBody.
private SoapBody getSoapBody(Class<?> parent) throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
SoapBody soapBody = null;
try {
soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapBody.setUse((String) env.get(ToolConstants.CFG_USE));
if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
soapBody.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
}
return soapBody;
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToSoapProcessor method setSoapBindingExtElement.
private void setSoapBindingExtElement() throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
SOAPBindingUtil.addSOAPNamespace(wsdlDefinition, isSOAP12());
SoapBinding soapBinding = null;
try {
soapBinding = SOAPBindingUtil.createSoapBinding(extReg, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapBinding.setStyle((String) env.get(ToolConstants.CFG_STYLE));
binding.addExtensibilityElement(soapBinding);
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToSoapProcessor method setSoapOperationExtElement.
private void setSoapOperationExtElement(BindingOperation bo) throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
SoapOperation soapOperation = null;
try {
soapOperation = SOAPBindingUtil.createSoapOperation(extReg, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapOperation.setStyle((String) env.get(ToolConstants.CFG_STYLE));
soapOperation.setSoapActionURI("");
bo.addExtensibilityElement(soapOperation);
}
Aggregations