cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Clegg <and...@nervechannel.com>
Subject Re: Getting WSDL or schema of service from inside a JAX-WS Provider
Date Thu, 19 Feb 2009 14:06:15 GMT
2009/2/19 Benson Margulies <bimargulies@gmail.com>:
> Who called Endpoint.publish()?

The first bit of your breadcrumb trail said "Endpoint.publish returns Endpoint."

> In case you haven't figured it out, I'm
> over my head at this point?

Fair enough :-)

Thanks for the pointers though. Anyone else done this?

Andrew.

>
> On Thu, Feb 19, 2009 at 8:50 AM, Andrew Clegg <andrew@nervechannel.com> wrote:
>> Okay... But I'm trying to do this from *inside* a Provider endpoint which
>> had already been published. Would I need to get cxf to inject the endpoint
>> in or something?
>>
>> Andrew.
>>
>>
>> On 19 Feb 2009, at 13:41, Benson Margulies <bimargulies@gmail.com> wrote:
>>
>>> No example that I know of, but here's the path to the candy house in
>>> the woods. Beware of witches with ovens.
>>>
>>> Endpoint.publish returns Endpoint. Endpoint can be cast to
>>> EndpointImpl. EndpointImpl returns Service. Service returns list of
>>> ServiceInfo. I don't understand exactly why it's a list, I keep
>>> meaning to ask Dan. I believe it will always return a singleton list,
>>> but if not find your particular service on the list, and then you have
>>> the item to pass to the function you found, which is extremely
>>> unlikely to melt.
>>>
>>> On Thu, Feb 19, 2009 at 8:30 AM, Andrew Clegg <andrew@nervechannel.com>
>>> wrote:
>>>>
>>>> Yeah, as long as you wouldn't say the API is likely to change in
>>>> future releases, I'm happy hooking into that. (And even if it does, I
>>>> can fall back to reading the WSDL myself). Is there an example that
>>>> demonstrates the necessary breadcrumbs?
>>>>
>>>> Cheers,
>>>>
>>>> Andrew.
>>>>
>>>> 2009/2/19 Benson Margulies <bimargulies@gmail.com>:
>>>>>
>>>>> Superfically, looks like you could call that API, yes. It's used
>>>>> internally to set up validation. Of course, you'd need to follow a
>>>>> trail of breadcrumbs to the CXF-specific Service object to get there.
>>>>> Is that the issue?
>>>>>
>>>>> On Thu, Feb 19, 2009 at 7:55 AM, Andrew Clegg <andrew@nervechannel.com>
>>>>> wrote:
>>>>>>
>>>>>> So the EndpointReferenceUtils.getSchema( serviceInfo ) approach is
>>>>>> only for @WebService classes and not @WebServiceProvider classes?
>>>>>>
>>>>>> Andrew.
>>>>>>
>>>>>> 2009/2/19 Benson Margulies <bimargulies@gmail.com>:
>>>>>>>
>>>>>>> CXF does not precisely have a 'copy' of the WSDL. It has a wsdl4j
>>>>>>> representation.
>>>>>>>
>>>>>>> On the 2.2 branch, there is an XmlSchemaCollection of the schemas.
In
>>>>>>> earlier branches, it has a DOM copy of them.
>>>>>>>
>>>>>>> We could, I suppose, expose. I'm hoping that Dan will wade in
at this
>>>>>>> point.
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Feb 19, 2009 at 5:42 AM, Andrew Clegg
>>>>>>> <andrew@nervechannel.com> wrote:
>>>>>>>>
>>>>>>>> Followup...
>>>>>>>>
>>>>>>>> So I've got this working by reading the WSDL myself in the
provider
>>>>>>>> class's constructor:
>>>>>>>>
>>>>>>>>
>>>>>>>> // First read WSDL
>>>>>>>> ClassLoader loader = this.getClass().getClassLoader();
>>>>>>>> InputStream wsdlFile = loader.getResourceAsStream( WSDL_NAME
);
>>>>>>>> Document wsdl = org.apache.cxf.helpers.DOMUtils.readXml(
wsdlFile );
>>>>>>>>
>>>>>>>> // Then get schema body from WSDL -- TODO tighten up query
using
>>>>>>>> namespaces
>>>>>>>> String schemaQuery =
>>>>>>>>
>>>>>>>> "//*[local-name()='definitions']/*[local-name()='types']/*[local-name()='schema']";
>>>>>>>> XPathExpression schemaPath = xp.compile( schemaQuery );
>>>>>>>> Node schemaNode = ( Node ) schemaPath.evaluate( wsdl,
>>>>>>>> XPathConstants.NODE );
>>>>>>>>
>>>>>>>> // Then compile it and store it
>>>>>>>> String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
>>>>>>>> SchemaFactory sf = SchemaFactory.newInstance( language );
>>>>>>>> DOMSource ds = new DOMSource( schemaNode );
>>>>>>>> this.schema = sf.newSchema( ds );
>>>>>>>>
>>>>>>>>
>>>>>>>> This lets me easily validate messages in the invoke() method,
for
>>>>>>>> example:
>>>>>>>>
>>>>>>>>
>>>>>>>> schema.newValidator().validate( domRequest );
>>>>>>>>
>>>>>>>>
>>>>>>>> where domRequest is the DOMSource of the message payload.
>>>>>>>>
>>>>>>>> However it still seems a little inelegant to read the WSDL
myself
>>>>>>>> when
>>>>>>>> CXF must have a copy.
>>>>>>>>
>>>>>>>> I've found the getSchema() method of the EndpointReferenceUtils
class
>>>>>>>> via an old thread on here, but that requires a ServiceInfo
object --
>>>>>>>> is there any way to acquire one of these for a Provider service?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Andrew.
>>>>>>>>
>>>>>>>> 2009/2/16 Andrew Clegg <andrew@nervechannel.com>:
>>>>>>>>>
>>>>>>>>> Hi folks,
>>>>>>>>>
>>>>>>>>> From inside a Provider implementation, how can I obtain
the schema
>>>>>>>>> of
>>>>>>>>> the service's request/response messages, short of reading
the WSDL
>>>>>>>>> myself and extracting the schema from it?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Andrew.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> :: http://biotext.org.uk/ ::
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> :: http://biotext.org.uk/ ::
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> :: http://biotext.org.uk/ ::
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> :: http://biotext.org.uk/ ::
>>>>
>>
>



-- 
:: http://biotext.org.uk/ ::

Mime
View raw message