Anil,

The problem is due to the fact that you are using a the default WSDLFactory
to create your definition and WSDLWriter. Registering extensions via WSIF
will only have an effect if you use the WSIFWSDLFactoryImpl factory class.
Also, since the EJB extensions are registered by default within WSIF, you
can simplify you main method to the following:


public static void main(String[] args)
{
  try
  {
    // Use the WSIF WSDLFactory
    // It picks up extensions registered by WSIF providers

    WSDLFactory factory = WSDLFactory.newInstance(
"org.apache.wsif.wsdl.WSIFWSDLFactoryImpl");
    Definition def = factory.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 = factory.newWSDLWriter();
    StringWriter stringWriter = new StringWriter();
    writer.writeWSDL(def, stringWriter);
    System.out.println(stringWriter.toString());
  }
  catch (Exception ex)
  {
    ex.printStackTrace();
  }
}


Regards,
Owen



|---------+---------------------------->
|         |           Anil             |
|         |           Ambati/Raleigh/IB|
|         |           [EMAIL PROTECTED]          |
|         |                            |
|         |           24/07/2003 23:35 |
|         |           Please respond to|
|         |           wsif-user        |
|         |                            |
|---------+---------------------------->
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                                              |
  |       To:       [EMAIL PROTECTED]                                                  
                                                        |
  |       cc:                                                                          
                                                              |
  |       Subject:  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
[EMAIL PROTECTED]
"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





Reply via email to