dims,
Thanks for the tip. Wished I'd known about it yesterday.
After more digging, I did figure out how to do this. The following
is a code snippet that adds the <message> with it's <part>, and
also the <soap:header> elements:
WSDLFactory factory = WSDLFactory.newInstance();
ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry();
WSDLReader reader = factory.newWSDLReader();
Part myPart = def.createPart();
myPart.setName("mySoapHeaderName");
myPart.setTypeName(new QName("xsd:string"));
Message myMessage = def.createMessage();
myMessage.setQName(new QName("myHeaderRequest"));
myMessage.setUndefined(false);
myMessage.addPart(myPart);
def.addMessage(JIMessage);
SOAPHeader myHeader
= (SOAPHeader)extReg.createExtension(BindingInput.class,
new QName
("http://schemas.xmlsoap.org/wsdl/soap/", "header"));
myHeader.setMessage(new QName("intf:myHeaderRequest"));
myHeader.setPart("mySoapHeaderName");
myHeader.setUse("encoded");
Service service = def.getService(new QName(targetNamespace,
"MyService"));
Port port = service.getPort("MyServicePort");
Binding binding = port.getBinding();
List operations = binding.getBindingOperations();
Iterator opIterator = operations.iterator();
while (opIterator.hasNext()) {
BindingOperation bindingOperation
= (BindingOperation)opIterator.next();
Operation operation = bindingOperation.getOperation();
if (!operation.isUndefined()) {
BindingInput bindingInput = bindingOperation.getBindingInput();
List extElements = bindingInput.getExtensibilityElements();
bindingInput.addExtensibilityElement(myHeader);
}
}
Steve Pannier
> There's another forum where you need to ask this -
> http://groups.yahoo.com/group/jsr110-eg-disc/
>
> Thanks,
> dims
> --- Steve Pannier <[EMAIL PROTECTED]> wrote:
> > We are using Axis 1.1, and we use the "Java2WSDL" tool to create WSDL
> > describing our already-existing services. We now want to include in the
> > generated WSDL a description of the Soap headers we support. I know
> > of no way for Axis's "Java2WSDL" to do this, so I am currently looking
at
> > using the WSDL4J API to programmatically add the soap:header elements
> > to the WSDL.
> >
> > Does anyone have example code showing how to do this? I'm using the
> > example code from the JSR110 (JWSDL) document to do the basic WSDL
> > traversal stuff, but I can't figure out how to create a SOAPHeader
> > ExtensibilityElement that I can add to the BindingInput. It's the
> > createExtension() method that I'm having problems with.
> >
> > A snippet of the code I have so far:
> >
> > ExtensionRegistry extReg = new ExtensionRegistry();
> > Service svc = def.getService(new QName(targetNamespace,
"MyService"));
> > Port port = svc.getPort("MyServicePort");
> > Binding binding = port.getBinding();
> > List ops = binding.getBindingOperations();
> > Iterator iter = ops.iterator();
> > while (iter.hasNext()) {
> > BindingOperation bo = (BindingOperation)iter.next();
> > BindingInput bi = bo.getBindingInput();
> > SOAPHeader sh
> > = (SOAPHeader)extReg.createExtension(BindingInput.class,
> > new QName("soap", "header"));
> > }
> >
> >
> > Any WSDL4J experts out there that can help me?
> >
> > Regards.
> >
> > Steve Pannier
> >
> >
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com