axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Chiurla <antoniochiu...@katamail.com>
Subject Re: How to set a value of type anyType in generated stub
Date Thu, 20 Dec 2007 09:29:50 GMT
Hi Dimuthu,

is correct the use of axiom_text_node, but the WebService I need to invoke
expect for this node the attribute "type" to define the type of metadata/value node.
I.E. the piece of SOAP request shold be same as:
<metadata>
  <metadataName>Name of string metadata</metadataName>
  <value xsi:type="xsd:string">value of metadata</value>
</metadata>

or

<metadata>
  <metadataName>Name of int metadata</metadataName>
  <value xsi:type="xsd:int">75</value>
</metadata>


in the soap:Envelope tag we need to add following attributes to define
the needed namespaces:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"


Trying to resolve this issue I have changed the generated stub in order to
send the attribute "type" after added the namespaces, I think that a possibile
generalized solution is to set an axiom_element:

  adb_metadataValue_t* ifs_mdv;
  axiom_element_t* my_axiom_element_value;
  axiom_attribute_t* my_axiom_attribute_value_type;
  axiom_node_t* my_axiom_node_value;


  adb_metadataValue_set_metadataName(my_mdv,env,"Name of string metadata");
  my_axiom_element_value = axiom_element_create(env,NULL,"value",NULL,&my_axiom_node_value);

  my_axiom_attribute_value_type = axiom_attribute_create(env, "type", "xs:string", NULL);
  axiom_element_add_attribute(my_axiom_element_value, env, my_axiom_attribute_value_type,
my_axiom_node_value);

  axiom_element_set_text(my_axiom_element_value,env,"value of metadata",my_axiom_node_value);
  adb_metadataValue_set_value(my_mdv,env,my_axiom_node_value);

Using this solution the stub generate the SOAP request as follow:

<metadata>
  <metadataName>Name of int metadata</metadataName>
  <value>
    <value xsi:type="xsd:int">75</value>
  </value>
</metadata>

The WebService can't parse correctly the previous SOAP request.

Then I propose to change the stub adding code to read, if present, the "type" attribute of
axiom_element and add this attribute in the "value" tag in adb_metadataValue_serialize
function.
Is this correct?

Thanks Antonio



On Wednesday 19 December 2007 19:07, Dimuthu Gamage wrote:
> BTW you will face the same problem as the one in
> https://issues.apache.org/jira/browse/AXIS2C-843. I will look in to
> that ASAP.
> 
> On Dec 19, 2007 11:17 PM, Dimuthu Gamage <dimuthuc@gmail.com> wrote:
> > Hi Antonio,
> >
> > If I m correct you are asking how to create string or int node so you
> > can assign it the variable with anytype.
> >
> > You can use 'axiom_text_create' to create text element and corresponding node.
> >
> > axiom_text_t* text_element;
> > axiom_node_t *text_node;
> >
> > text_element = axiom_text_create(env,
> >  NULL /* no parent at start */,
> >  "SomeString" /* your string */,
> >  &text_node);
> >
> > here you can set the text_node to the setter method of the above struct.
> >
> > you may set int, float values after converting them to string (May be
> > using sprintf)
> >
> > Check http://ws.apache.org/axis2/c/docs/om_tutorial.html Code Listing
> > 6 for an example.
> >
> > Thanks
> > Dimuthu
> >
> >
> >
> >
> > On Dec 19, 2007 10:56 PM, Antonio Chiurla <antoniochiurla@katamail.com> wrote:
> > > Hi,
> > > I have to set a value defined as anyType in wsdl and relative xsd:
> > >
> > > <xs:sequence>
> > > <xs:element minOccurs="0" name="metadataName" type="xs:string"/>
> > > <xs:element minOccurs="0" name="value" type="xs:anyType"/>
> > > </xs:sequence>
> > >
> > > I have generated the stub for this wsdl and the struct defined
> > > to pass to the op contains a field of type axiom_node_t*
> > >
> > >         struct adb_metadataValue
> > >         {
> > >             axis2_char_t* property_metadataName;
> > >
> > >
> > >                 axis2_bool_t is_valid_metadataName;
> > >
> > >             axiom_node_t* property_value;
> > >
> > >
> > >                 axis2_bool_t is_valid_value;
> > >
> > >
> > >         };
> > >
> > >
> > > I need to insert a string or int or other types depending of
> > > some conditions verified at runtime.
> > >
> > >
> > > Thanks
> > >
> > > Antonio Chiurla
> > >
> > >
> > > -------------------------------------------------------
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-c-user-help@ws.apache.org
> > >
> > >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> 
>

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


Mime
View raw message