use of javax.wsdl.WSDLException in project cxf by apache.
the class ReflectionServiceFactorBeanTest method testEmptyWsdlAndNoServiceClass.
@Test
public void testEmptyWsdlAndNoServiceClass() throws Exception {
final String dummyWsdl = "target/dummy.wsdl";
ReflectionServiceFactoryBean bean = new ReflectionServiceFactoryBean();
Bus bus = control.createMock(Bus.class);
WSDLManager wsdlmanager = control.createMock(WSDLManager.class);
EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(wsdlmanager);
EasyMock.expect(wsdlmanager.getDefinition(dummyWsdl)).andThrow(new WSDLException("PARSER_ERROR", "Problem parsing '" + dummyWsdl + "'."));
EasyMock.expect(bus.getExtension(FactoryBeanListenerManager.class)).andReturn(null);
control.replay();
bean.setWsdlURL(dummyWsdl);
bean.setServiceName(new QName("http://cxf.apache.org/hello_world_soap_http", "GreeterService"));
bean.setBus(bus);
try {
bean.create();
fail("no valid wsdl nor service class specified");
} catch (ServiceConstructionException e) {
// ignore
}
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class OperationVisitor method generateBindingOperation.
private BindingOperation generateBindingOperation(Binding wsdlBinding, Operation op, String corbaOpName) {
BindingOperation bindingOperation = definition.createBindingOperation();
// OperationType operationType = null;
try {
corbaOperation = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException ex) {
throw new RuntimeException(ex);
}
corbaOperation.setName(corbaOpName);
bindingOperation.addExtensibilityElement((ExtensibilityElement) corbaOperation);
bindingOperation.setOperation(op);
bindingOperation.setName(op.getName());
binding.addBindingOperation(bindingOperation);
return bindingOperation;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class PortTypeVisitor method createBinding.
public Binding createBinding(String scopedPortTypeName) {
StringBuilder bname = new StringBuilder();
bname.append(scopedPortTypeName).append("CORBABinding");
QName bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
int count = 0;
while (queryBinding(bqname)) {
bname.append(count);
bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
}
Binding binding = rootDefinition.createBinding();
binding.setPortType(portType);
binding.setQName(bqname);
try {
BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
String pragmaPrefix = (this.getWsdlVisitor().getPragmaPrefix() != null && this.getWsdlVisitor().getPragmaPrefix().length() > 0) ? this.getWsdlVisitor().getPragmaPrefix() + "/" : "";
bindingType.setRepositoryID(CorbaConstants.REPO_STRING + pragmaPrefix + scopedPortTypeName.replace('.', '/') + CorbaConstants.IDL_VERSION);
binding.addExtensibilityElement((ExtensibilityElement) bindingType);
} catch (WSDLException ex) {
throw new RuntimeException(ex);
}
binding.setUndefined(false);
rootDefinition.addBinding(binding);
return binding;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDL11Validator method isValid.
public boolean isValid() throws ToolException {
// boolean isValid = true;
String schemaDir = getSchemaDir();
String[] schemas = (String[]) env.get(ToolConstants.CFG_SCHEMA_URL);
// Tool will use the following sequence to find the schema files
// 1.ToolConstants.CFG_SCHEMA_DIR from ToolContext
// 2.ToolConstants.CXF_SCHEMA_DIR from System property
// 3.If 1 and 2 is null , then load these schema files from jar file
String wsdl = (String) env.get(ToolConstants.CFG_WSDLURL);
Document doc = getWSDLDoc(wsdl);
if (doc == null) {
return true;
}
if (this.def == null) {
try {
this.def = getBus().getExtension(WSDLManager.class).getDefinition(wsdl);
} catch (WSDLException e) {
throw new ToolException(e);
}
}
WSDLRefValidator wsdlRefValidator = new WSDLRefValidator(this.def, doc, getBus());
wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
validators.add(wsdlRefValidator);
if (env.fullValidateWSDL()) {
validators.add(new UniqueBodyPartsValidator(this.def));
validators.add(new WSIBPValidator(this.def));
validators.add(new MIMEBindingValidator(this.def));
}
boolean notValid = false;
for (AbstractValidator validator : validators) {
if (!validator.isValid()) {
notValid = true;
addErrorMessage(validator.getErrorMessage());
}
}
if (notValid) {
throw new ToolException(this.getErrorMessage());
}
// By default just use WsdlRefValidator
if (!env.fullValidateWSDL()) {
return true;
}
final SchemaValidator schemaValidator;
if (!StringUtils.isEmpty(schemaDir)) {
schemaValidator = new SchemaValidator(schemaDir, wsdl, schemas);
} else {
try {
schemaValidator = new SchemaValidator(getDefaultSchemas(), wsdl, schemas);
} catch (IOException e) {
throw new ToolException("Schemas can not be loaded before validating wsdl", e);
}
}
if (!schemaValidator.isValid()) {
this.addErrorMessage(schemaValidator.getErrorMessage());
throw new ToolException(this.getErrorMessage());
}
return true;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class Wsdl11AttachmentPolicyProviderTest method oneTimeSetUp.
@BeforeClass
public static void oneTimeSetUp() throws Exception {
IMocksControl control = EasyMock.createNiceControl();
Bus bus = control.createMock(Bus.class);
WSDLManager manager = new WSDLManagerImpl();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
control.replay();
int n = 19;
services = new ServiceInfo[n];
endpoints = new EndpointInfo[n];
for (int i = 0; i < n; i++) {
String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
try {
services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
} catch (WSDLException ex) {
ex.printStackTrace();
fail("Failed to build service from resource " + resourceName);
}
assertNotNull(services[i]);
endpoints[i] = services[i].getEndpoints().iterator().next();
assertNotNull(endpoints[i]);
}
control.verify();
}
Aggregations