Hello Paul,
This is an XML language that allows you to specify parameters (the WSDL being referenced, the message to be used as input, the port type and operation being targetted) for dynamic invocation of a web service. Is that an accurate statement?
If so, your problem is how to convert the message the user specified into a format the target web service can consume, if I understand correctly. In order to do your invocation using WSIF, you will need to
1. parse your XML
2. identify the endpoint programmatically (you will create a WSIFService object using the WSDL information, then get to a WSIFOperation object using the port type and operation name information - see samples and tests)
3. create the WSIF message from your XML message. You would extract the information from your XML and convert into java objects, then populate a WSIF message. You would need to deserialize the values from your XML language into a java type. If you use a standard encoding such as SOAP encoding or literal encoding (see SOAP encoding styles in the WSDL spec or section 5 of the SOAP spec for details), this conversion from the XML into java can be automatic.
4. do the invocation
An alternative is to just convert your XML into a SOAP message directly, using XSLT or some java code. This is possible as long as the encoding style you use for message parts matches that expected by the target web service. You can actually redefine your XML syntax so that messages look more like SOAP messages, in which case the transformation will be simple. The drawback to this approach is that you will not be able to access services unless they have SOAP bindings (fortunately it is rare for a web service to not have a SOAP binding).
For more information on the Google web service APIs, you can refer to http://www.google.com/apis/. If you download the developer kit from there, the soap-samples directory shows some example SOAP messages.
Thanks,
Nirmal.
| Paul Duffin <[EMAIL PROTECTED]>
02/20/2003 11:05 AM
|
To: [EMAIL PROTECTED] cc: Subject: Re: Using XML to represent web service invocation. |
Thanks for your quick response, I should have followed my own advice and
added an example.
WSDL gives an abstract description of the contents of each message part
in terms of XML Schema (I will ignore other typing systems such as Relax
NG for now). It does not however give an abstract description of the
whole message.
For the purposes of this task I will define the abstract description of
the whole message as follows.
Each message part will be represented by an element whose local name is
the same as the name of the message part. The namespace is irrelevant to
me at the moment so I will treat as empty. This element is known as the
*part element*. The parts of the message are contained within a
<message> element (not the same as the WSDL).
If the message part is defined by an element then the body content of
the part element will be just that element. If the message part is
defined by a type then the part element is of that type.
e.g. given the following message description
<message ...>
<part name="p1" type="xs:string"/>
<part name="p2" element="ns:some-element"/>
</message>
the virtual schema would be something like
<xs:element name="message">
<xs:complexType>
<xs:sequence>
<xs:element name="p1" type="xs:string"/>
<xs:element name="p2">
<xs:complexType>
<xs:choice>
<xs:element ref="ns:some-element"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
and a valid XML message would look something like.
<message>
<p1>A string</p1>
<p2><ns:some-element ...>...</ns:some-element></p2>
</message>
(I am not sure that the mapping I have defined above is the best one to
use but it will do for now).
In the following example I use the GoogleSearch WSDL
http://api.google.com/GoogleSearch.wsdl
An XML representation of the doGoogleSearch message would be something like
<message>
<key>Key</key>
<q>QQQQ</q>
<start>12</start>
<maxResults>15</maxResults>
<filter>false</filter>
<restrict>XYZ</restrict>
<safeSearch>true</safeSearch>
<lr>LR</lr>
<ie>IE</ie>
<oe>OE</oe>
</message>
What I need to do is transform the above XML representation into a
binding specific format that I can send to the Web Service. Google only
defines one binding for that message which is to use encoded SOAP.RPC
over HTTP.
The main problem I have is that I do not know how the above message
would look in that binding. I have tried to find examples that would
show this but cannot find any.
So what would the SOAP message look like that was generated from the
above message ?
Nirmal Mukhi wrote:
>
> Hello Paul,
>
> I'm not sure what you are asking. Let me briefly describe WSDL messages
> and how they relate to an invocation in WSIF.
>
> WSDL 1.1 describes how WSDL message parts are mapped to a SOAP message.
> Usually one needs to specify in the binding where the WSDL message part
> goes in within the SOAP envelope (for example if it part of the SOAP
> header or message body), and what the encoding is (SOAP specifies
> standard ways of representing structured data in XML; this is used to
> convert the message part, defined according to a particular schema, into
> the XML that goes in a SOAP envelope). That is all one needs to know.
>
> As another example, the java binding defined in WSIF maps abstract WSDL
> message parts to parameters in a java method invocation. The message
> types (i.e. the schema types) are mapped to java types.
>
> The WSIF API lets you make "abstract invocations". Roughly speaking, as
> you described, you identify the WSDL, port type and operation, create
> the necessary WSIF messages and do the invocation. A WSIF message
> mirrors a WSDL abstract message: it is essentially a map of part names
> to values. The value for a particular part in the WSIF message must be
> permissible for the corresponding schema type for that WSDL message. For
> example if the WSDL message part is of schema type string, the value of
> the corresponding WSIF message part must be a java.lang.String and so
> on. Once you create your input message properly WSIF does the invocation
> using an appropriate binding (or the one you might have specified),
> taking care of message conversions as required by that particular
> protocol - for example, serialization into XML in case you use a SOAP
> binding.
>
> Hope that helps,
> Nirmal.
>
>
> *Paul Duffin <[EMAIL PROTECTED]>*
>
> 02/20/2003 06:41 AM
> Please respond to wsif-user
>
>
> To: [EMAIL PROTECTED]
> cc:
> Subject: Using XML to represent web service invocation.
>
>
>
>
> As I understand it the WSIF is designed to allow Java code to
> programmatically invoke any web service that has a wsdl description. The
> client code does not have to know anything about specific bindings or
> locations of web services, they just provide a url to the wsdl, the name
> of the operation they want to invoke and any 'parameters'.
>
> Assuming that the above is a correct (and probably simplistic) summary I
> need to do a very similar thing except that I need to represent the web
> service invocation using an abstract XML representation instead of
> coding it directly into Java.
>
> The WSDL contains an abstract XML representation of a message and so I
> would like to use that if I could as it seems perfect for it. Section
> 2.3.2 of WSDL Note (http://www.w3.org/TR/wsdl#_abstract-v) even says
>
> > Message definitions are always considered to be an abstract
> > definition of the message content. A message binding describes how
> > the abstract content is mapped into a concrete format. However, in
> > some cases, the abstract definition may match the concrete
> > representation very closely or exactly for one or more bindings, so
> > those binding(s) will supply little or no mapping information.
> > However, another binding of the same message definition may require
> > extensive mapping information. For this reason, it is not until the
> > binding is inspected that one can determine "how abstract" the
> > message really is.
>
> The first two sentences indicate to me that it should be possible to
> provide mappings direct from the abstract message format through to the
> underlying bindings. These mappings would only depend on the abstract
> message format and the binding type, they would not need application
> specific knowledge such as is required for mapping from Java objects
> through to specific bindings.
>
> However, my problem is that I cannot seem to find any confirmation of my
> interpretation of the specification, either through examples of how it
> can be done, or code to actually do it.
>
> I have read the WSDL many times now and the binding definitions do not
> seem to elaborate on ".. how the abstract content is mapped into a
> concrete format.". In particular it seems to be in need of a lot of
> examples that show how abstract message definitions (in XML Schema) are
> represented in each binding.
>
> As WSIF operates at a similar abstract level I was wondering whether
> anyone on this group could enlighten me on whether it is possible and if
> so how, or even better tell me that WSIF already does this.
>
> If it is not possible for all binding types / WSDL structures then I am
> prepared to limit its applicability, such as to the WS-I Basic Profile.
>
> http://www.ws-i.org/Profiles/Basic/2003-01/BasicProfile-1.0-WGD.pdf
>
>
