You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-user@ws.apache.org by Anil Ambati <aa...@us.ibm.com> on 2003/07/25 00:35:59 UTC
Create WSDL Definition in memory
Hi,
I have a need to create WSDL definitions dynamically. The interface of the
service is static. The binding and address extensibility element of Port
will change. I would like to know if any body have done this before and
would send me examples.
I started to do this to accomplish this.
public static ExtensibilityElement getEjbAddressExtElement()
{
EJBAddress ejbAddress = new EJBAddress();
ejbAddress.setJndiName("ejb/org/apache/TestBean");
ejbAddress.setJndiProviderURL("iiop://localhost:2809/");
ejbAddress.setInitialContextFactory(
"com.ibm.websphere.naming.WsnInitialContextFactory");
ejbAddress.setClassName("org.apache.TestBeanHome");
return ejbAddress;
}
public static void main(String[] args)
{
try
{
WSIFServiceImpl.addExtensionRegistry(
new EJBExtensionRegistry());
WSIFPluggableProviders.overrideDefaultProvider(
"http://schemas.xmlsoap.org/wsdl/ejb/",
new WSIFDynamicProvider_EJB());
Definition def = WSDLFactoryImpl.newInstance().newDefinition();
Port port = def.createPort();
port.setName("SinkPort");
port.addExtensibilityElement(getEjbAddressExtElement());
Service fireflySubscriberService = def.createService();
QName serviceName = new QName("http://xxx.yyy.com/wsdl/",
"SinkService");
fireflySubscriberService.setQName(serviceName);
fireflySubscriberService.addPort(port);
def.addService(fireflySubscriberService);
WSDLWriter writer = WSDLFactoryImpl.newInstance().newWSDLWriter();
StringWriter stringWriter = new StringWriter();
writer.writeWSDL(def, stringWriter);
System.out.println(stringWriter.toString());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
But, I am getting the following exception:
[INFO] wsif - -WSIF0007I: Using WSIFProvider
'org.apache.wsif.providers.ejb.WSIFDynamicProvider_EJB' for namespaceURI
'http://schemas.xmlsoap.org/wsdl/ejb/'
java.lang.ClassCastException:
org.apache.wsif.wsdl.extensions.ejb.EJBAddress
at javax.wsdl.extensions.UnknownExtensionSerializer.marshall(Unknown
Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printExtensibilityElements(Unknown
Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printPorts(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printServices(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printDefinition(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.writeWSDL(Unknown Source)
at wsdl.test.CreateWSDL.main(CreateWSDL.java:73)
Thanks in advance for your help.
Regards,
Anil Ambati
SDWB Development
919-254-6152
aambati@us.ibm.com
"You have no responsibility to live up to what other people think you ought
to accomplish." -Richard Feynman (1918-1988)
"Money is as bad as it is necessary" - Anonymous