You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-user@ws.apache.org by Erik Rissanen <mi...@sics.se> on 2007/05/19 13:11:13 UTC

Problem with namespace prefix in notifications

Hello,

I am having an issue with Muse and notifications.

I have a service which processes a request and I want to generate a
notification about this request and the corresponding response.

I am creating the notification like the following in the code. Response
and respDoc are the request and response which I want to include in the
notification.

        QName messageName = new QName(NAMESPACE_URI, "AccessRequest",
PREFIX);
        Element payload = XmlUtils.createElement(messageName);
        Node importedReq =
payload.getOwnerDocument().importNode(Request, true);
        Node importedResp = payload.getOwnerDocument().importNode
        (respDoc.getDocumentElement(), true);
        payload.appendChild(importedReq);
        payload.appendChild(importedResp);
        NotificationProducer wsn = (NotificationProducer)
        getResource().getCapability(WsnConstants.PRODUCER_URI);
        wsn.publish(topic_name, payload);

The XML which I include as children in the message do not use namespace
prefixes, but a default namespace (xmlns="...").

Muse seems to try to collect the namespace prefixes from the message
contents, which causes broken XML like this:

<wsnt:NotificationMessage
    xmlns:="urn:oasis:names:tc:xacml:3.0:schema:os"
    ....
>
    ....
    <wsnt:Message>
        <tns:AccessRequest
            xmlns:tns="...">
            <Request
                xmlns="urn:oasis:names:tc:xacml:3.0:schema:os">
    ....

(Note the xmlns:="..." on the second line.)

I have not tried to trace the source of this error in the code. I think
that for now I will just rewrite the XML before it is included in the
notification message.

Is this a bug in Muse? (Or did I do something wrong.) If it is a bug, I
can create a bug tracking item for it.

Regards,
Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


Re: Problem with namespace prefix in notifications

Posted by Kam Yee <kk...@us.ibm.com>.
I've encountered the same situation that Erik describes.

Another, likely related case, is that the topicName also expects an 
explicit namespace prefix.

The following invocation (which is similar to what is shown in one of the 
samples):
        wsn.publish(new QName("http://www.abc.com/Topics", "Default"), 
payload);

Results in the following invalid segment in the NotificationMessage:
        <wsnt:Topic 
Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete" 
xmlns:="http://www.abc.com/Topics">Default</wsnt:Topic>

If the publish invocation is modified so that the QName declares the 
prefix, then the message is generated is valid.
        wsn.publish(new QName("http://www.abc.com/Topics", "Default", 
"xyz"), payload);

Is this the same bug as described by Erik (assuming it is a bug)?


Regards,
Kam Yee





Erik Rissanen <mi...@sics.se> 
05/19/2007 07:11 AM
Please respond to
muse-user@ws.apache.org


To
muse-user@ws.apache.org
cc

Subject
Problem with namespace prefix in notifications






Hello,

I am having an issue with Muse and notifications.

I have a service which processes a request and I want to generate a
notification about this request and the corresponding response.

I am creating the notification like the following in the code. Response
and respDoc are the request and response which I want to include in the
notification.

        QName messageName = new QName(NAMESPACE_URI, "AccessRequest",
PREFIX);
        Element payload = XmlUtils.createElement(messageName);
        Node importedReq =
payload.getOwnerDocument().importNode(Request, true);
        Node importedResp = payload.getOwnerDocument().importNode
        (respDoc.getDocumentElement(), true);
        payload.appendChild(importedReq);
        payload.appendChild(importedResp);
        NotificationProducer wsn = (NotificationProducer)
        getResource().getCapability(WsnConstants.PRODUCER_URI);
        wsn.publish(topic_name, payload);

The XML which I include as children in the message do not use namespace
prefixes, but a default namespace (xmlns="...").

Muse seems to try to collect the namespace prefixes from the message
contents, which causes broken XML like this:

<wsnt:NotificationMessage
    xmlns:="urn:oasis:names:tc:xacml:3.0:schema:os"
    ....
>
    ....
    <wsnt:Message>
        <tns:AccessRequest
            xmlns:tns="...">
            <Request
                xmlns="urn:oasis:names:tc:xacml:3.0:schema:os">
    ....

(Note the xmlns:="..." on the second line.)

I have not tried to trace the source of this error in the code. I think
that for now I will just rewrite the XML before it is included in the
notification message.

Is this a bug in Muse? (Or did I do something wrong.) If it is a bug, I
can create a bug tracking item for it.

Regards,
Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org



Re: Problem with namespace prefix in notifications

Posted by Kam Yee <kk...@us.ibm.com>.
To close on this thread, may I suggest that the online sample (
http://ws.apache.org/muse/docs/2.2.0/manual/how-to/publish-any-notification.html) 
be updated/fixed to reflect and explicitly point out the fact that the 
prefix is mandatory.

As it is shown now, someone new would run straight into the problem.

Regards,
Kam Yee





Daniel Jemiolo/Durham/IBM@IBMUS 
05/21/2007 12:21 PM
Please respond to
muse-user@ws.apache.org


To
muse-user@ws.apache.org
cc

Subject
Re: Problem with namespace prefix in notifications











Hi,

This bug is well-known but is not part of the Muse code base - we
documented it here:


http://ws.apache.org/muse/docs/2.2.0/manual/troubleshooting/default-namespaces-xerces.html


As Kam discovered, using the three-param constructor and making QNames 
with
prefixes fixes the problem.

Dan



Erik Rissanen <mi...@sics.se> wrote on 05/19/2007 07:11:13 AM:

> Hello,
>
> I am having an issue with Muse and notifications.
>
> I have a service which processes a request and I want to generate a
> notification about this request and the corresponding response.
>
> I am creating the notification like the following in the code. Response
> and respDoc are the request and response which I want to include in the
> notification.
>
>         QName messageName = new QName(NAMESPACE_URI, "AccessRequest",
> PREFIX);
>         Element payload = XmlUtils.createElement(messageName);
>         Node importedReq =
> payload.getOwnerDocument().importNode(Request, true);
>         Node importedResp = payload.getOwnerDocument().importNode
>         (respDoc.getDocumentElement(), true);
>         payload.appendChild(importedReq);
>         payload.appendChild(importedResp);
>         NotificationProducer wsn = (NotificationProducer)
>         getResource().getCapability(WsnConstants.PRODUCER_URI);
>         wsn.publish(topic_name, payload);
>
> The XML which I include as children in the message do not use namespace
> prefixes, but a default namespace (xmlns="...").
>
> Muse seems to try to collect the namespace prefixes from the message
> contents, which causes broken XML like this:
>
> <wsnt:NotificationMessage
>     xmlns:="urn:oasis:names:tc:xacml:3.0:schema:os"
>     ....
> >
>     ....
>     <wsnt:Message>
>         <tns:AccessRequest
>             xmlns:tns="...">
>             <Request
>                 xmlns="urn:oasis:names:tc:xacml:3.0:schema:os">
>     ....
>
> (Note the xmlns:="..." on the second line.)
>
> I have not tried to trace the source of this error in the code. I think
> that for now I will just rewrite the XML before it is included in the
> notification message.
>
> Is this a bug in Muse? (Or did I do something wrong.) If it is a bug, I
> can create a bug tracking item for it.
>
> Regards,
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: muse-user-help@ws.apache.org
>

Re: Problem with namespace prefix in notifications

Posted by Daniel Jemiolo <da...@us.ibm.com>.




Hi,

This bug is well-known but is not part of the Muse code base - we
documented it here:


http://ws.apache.org/muse/docs/2.2.0/manual/troubleshooting/default-namespaces-xerces.html

As Kam discovered, using the three-param constructor and making QNames with
prefixes fixes the problem.

Dan



Erik Rissanen <mi...@sics.se> wrote on 05/19/2007 07:11:13 AM:

> Hello,
>
> I am having an issue with Muse and notifications.
>
> I have a service which processes a request and I want to generate a
> notification about this request and the corresponding response.
>
> I am creating the notification like the following in the code. Response
> and respDoc are the request and response which I want to include in the
> notification.
>
>         QName messageName = new QName(NAMESPACE_URI, "AccessRequest",
> PREFIX);
>         Element payload = XmlUtils.createElement(messageName);
>         Node importedReq =
> payload.getOwnerDocument().importNode(Request, true);
>         Node importedResp = payload.getOwnerDocument().importNode
>         (respDoc.getDocumentElement(), true);
>         payload.appendChild(importedReq);
>         payload.appendChild(importedResp);
>         NotificationProducer wsn = (NotificationProducer)
>         getResource().getCapability(WsnConstants.PRODUCER_URI);
>         wsn.publish(topic_name, payload);
>
> The XML which I include as children in the message do not use namespace
> prefixes, but a default namespace (xmlns="...").
>
> Muse seems to try to collect the namespace prefixes from the message
> contents, which causes broken XML like this:
>
> <wsnt:NotificationMessage
>     xmlns:="urn:oasis:names:tc:xacml:3.0:schema:os"
>     ....
> >
>     ....
>     <wsnt:Message>
>         <tns:AccessRequest
>             xmlns:tns="...">
>             <Request
>                 xmlns="urn:oasis:names:tc:xacml:3.0:schema:os">
>     ....
>
> (Note the xmlns:="..." on the second line.)
>
> I have not tried to trace the source of this error in the code. I think
> that for now I will just rewrite the XML before it is included in the
> notification message.
>
> Is this a bug in Muse? (Or did I do something wrong.) If it is a bug, I
> can create a bug tracking item for it.
>
> Regards,
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: muse-user-help@ws.apache.org
>