axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dustfinger x <dustfin...@muddymukluk.com>
Subject namespace not showing in xml returned from RESTful service
Date Mon, 04 Apr 2011 00:16:20 GMT
Greetings,

I have created a simple RESTful service and one of my GET service operations
returns xml with a namespace and prefix. The prefix displays for every node
in the returned xml fragment, but the namespace is not displayed.

At the top of my service skeleton source file I have declared the following
constant to serve as the namespace uri.
// code snippet BEGIN
const string NAME_SPACE = "http://www.example.net/xml/2011";
axiom_namespace_t* myNameSpace;
// code snippet END

I then create the namespace in the skeletonInvoke method before I have
resolved which operation to invoke:

// code snippet BEGIN
myNameSpace = axiom_namespace_create(
        environment,
        NAME_SPACE.c_str(),
        "my");
// code snippet END

In my service operation I create the root node and root element of the xml
fragment with the namespace. All of the children are also created with the
same namespace as illustrated in the following code snippet:
// code snippet BEGIN
root_om_ele = axiom_element_create(environment, NULL, "RootNode",
myNameSpace, &root_om_node);
//...
child_om_ele = axiom_element_create(environment, root_om_node, "ChildNode",
myNameSpace, &child_om_node);
// code snippet END

I free the namespace in the skeletonFree method:

// code snippet BEGIN
 if(myNameSpace){
    axiom_namespace_free(myNameSpace,environment);
    myNameSpace = NULL;
  }
// code snippet END

When I query the resource from firefox the xml fragment is returned without
the namespace. Also, firefox displays the following message at the top of
the page:
This XML file does not appear to have any style information associated with
it. The document tree is shown below.

//Example Output BEGIN
<my:RootNode>
<my:ChildNode>
</my:ChildNode>
</my:RootNode>
//Example Output END

QUESTION:

How do I properly form an XML response with a namespace?

Sincerely,

dustfinger

Mime
View raw message