Si quieres modificar los tipos de datos de un WSDL usa la implememtacion de la especificacion JSWDL llamada wsdl4j
javax.wsdl.xml.WSDLWriter wsdlWriter= javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
javax.wsdl.xml.WSDLReader wsdlReader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
Definition wsdlDefinition =(Definition) wsdlReader.readWSDL(wsdlfile);
//elimina el esquema de datos antiguo
javax.wsdl.Types type=wsdlDefinition.getTypes();
for (Object e : type.getExtensibilityElements()) {
if (e instanceof com.ibm.wsdl.extensions.schema.SchemaImpl) {
//schema = (com.ibm.wsdl.extensions.schema.SchemaImpl)e;
//TODO:erase all schema
type.getExtensibilityElements().remove(e);
break;
}
}
//importa el el nuevo esquema de tipo de datos
com.ibm.wsdl.extensions.schema.SchemaImpl schema;
schema = (com.ibm.wsdl.extensions.schema.SchemaImpl) wsdlDefinition.getExtensionRegistry()
.createExtension(javax.wsdl.Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema"));
//com.ibm.wsdl.extensions.schema.SchemaImpl schema = new com.ibm.wsdl.extensions.schema.SchemaImpl();
SchemaReference schemaReference = new SchemaReferenceImpl();
schemaReference.setSchemaLocationURI("http://localhost:8000/allTypes2.xsd");
schema.addInclude(schemaReference);
type.addExtensibilityElement(schema);
wsdlDefinition.addNamespace(ns, nameSpace);
File file2 = new File("newwsdl.wsdl");
BufferedWriter output;
try {
output = new BufferedWriter(new FileWriter(file2));
wsdlWriter.writeWSDL(wsdlDefinition, output);
output.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
No comments:
Post a Comment