Ann,
Thanks for the response. Here's my dilemma:
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 that's why I am looking at the
WSDL4J API to programmatically add the soap:header
elements to the WSDL (doing this manually is not an option).
Our soap headers are not complex types, just simple strings.
So, would I be correct in assuming that I would not need to
define anything in the <types> section?
Also (for any WSDL4J experts out there), 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 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();
BindingInput bindingInput =
bindingOperation.getBindingInput();
SOAPHeader soapHeader =
(SOAPHeader)extReg.createExtension(BindingInput.class,
new QName("soap", "header"));
}
}
Any other ideas as to how to attack my problem? Or are
there any WSDL4J experts out there that can help me?
Regards.
Steve Pannier
> Per the WSDL spec, the soap:header element [1] is constructed as follows:
>
> <soap:header message="qname" part="nmtoken" use="literal|encoded"
> encodingStyle="uri-list"? namespace="uri"?>*
>
> The message="qname" and part="nmtoken" attributes refer to a message
<part>
> element [2], and you must define that message <part>.
>
> <message name="nmtoken"> *
> <part name="nmtoken" element="qname"? type="qname"?/> *
> </message>
>
> The wsdl:part requires either an element or a type attribute. If you were
> sending a simple type, then you could just specify type="xsd:string" and
use
> SOAP encoding to format the header for you. But you want to send a
complex
> element, so you must define the element structure, which you do in the
> <types> section.
>
> [1] http://www.w3.org/TR/wsdl#_soap:header
> [2] http://www.w3.org/TR/wsdl#_messages
>
> Perhaps someone else can provide a WSDL4J code sample? (but I don't think
> that WSDL4J provides a Schema API -- which is necessary for creating the
> <types> section).
>
> Anne
>
> ----- Original Message -----
> From: "Steve Pannier" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 30, 2003 12:52 PM
> Subject: Re: Adding header info to WSDL
>
>
> > A couple questions:
> >
> > 1) Do you have any examples of doing this programmatically using the
> WSDL4J
> > API?
> >
> > 2) Why do I need to add stuff to the "types" and "part" sections of the
> > WSDL? The spec only mentions
> > the soap:header element in the binding input section when talking
> > about Soap Header support.
> >
> > Regards.
> >
> > Steve Pannier
> >
> >
> > ----- Original Message -----
> > Yes.
> > - define the <authentication> element in the <types> section.
> > - define an additional <part> in your input message and reference the
> > authentication element.
> > - add a <soap:header> element to the <input> element in the <binding>
and
> > reference the header message part (see [1])
> >
> > [1] http://www.w3.org/TR/wsdl#_soap:header
> >
> > Anne
> >
> > ----- Original Message -----
> > From: "Sam Khan" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, July 28, 2003 4:26 PM
> > Subject: Adding header info to WSDL
> >
> >
> > > Hi,
> > >
> > > Is it possible to specify header parameters in a web service's WSDL ?
> > > Specifically, I want
> > > to ensure that a client sends the following elements in a SOAP
header:
> > >
> > > <authentication>
> > > <username></username>
> > > <password></password>
> > > </authentication>
> > >
> > > Can this be enforced in the WSDL?
> > >
> > > Many thanks
> > > Sam
> > >
> > >
> >
> >
>