XML attributes instead of elements in data contract serialisation in Rest WCF implementation

I want to uses XML attributes instead of elements, I implemented IXmlSerializable and
public partial class Id : IXmlSerializable {
/// <remarks/>
[XmlAttribute]
public string lmsId;
/// <remarks/>
[XmlAttribute]
public string unitId;
/// <remarks/>
[XmlAttribute]
public string lmsPresId;
/// <remarks/>
[XmlAttribute]
public string callId;
public System.Xml.Schema.XmlSchema GetSchema()
return null;
public void ReadXml(System.Xml.XmlReader reader)
//implement if remote callers are going to pass your object in
public void WriteXml(System.Xml.XmlWriter writer)
writer.WriteAttributeString("lmsId", lmsId.ToString());
writer.WriteAttributeString("unitId", unitId.ToString());
writer.WriteAttributeString("lmsPresId", lmsPresId.ToString());
writer.WriteAttributeString("callId", callId.ToString());
But my service help is showing request and response as unknown
I tried even XmlSerializerFormat public partial class Id : IXmlSerializable {
/// <remarks/>
[XmlAttribute]
public string lmsId;
/// <remarks/>
[XmlAttribute]
public string unitId;
/// <remarks/>
[XmlAttribute]
public string lmsPresId;
/// <remarks/>
[XmlAttribute]
public string callId;
public System.Xml.Schema.XmlSchema GetSchema()
return null;
public void ReadXml(System.Xml.XmlReader reader)
//implement if remote callers are going to pass your object in
public void WriteXml(System.Xml.XmlWriter writer)
writer.WriteAttributeString("lmsId", lmsId.ToString());
writer.WriteAttributeString("unitId", unitId.ToString());
writer.WriteAttributeString("lmsPresId", lmsPresId.ToString());
writer.WriteAttributeString("callId", callId.ToString());
then I am getting everything in the xml as xmlElements instead of XmlAttributes But I am getting all the data as elements instead of Xmlattributes

I will test it.
I sale myself ONLY half CNY!

Similar Messages

  • How to add XML attribute to an Element using BPEL assign

    I have a request xml to a bpel process that does not contain a attribute.
    After some process I need to create this missing attribute and set a value.
    I tried using the XML fragment in the Assign Activity. But how can I create a attribute?
    This XML node to which I am trying to create an attribute is a very huge node with lot of dynamic typing(xsi:type). I can just re-create the complete xml with required nodes.
    Does any one know how I can create a xml attribute using the BPEL assign? I do not want to use the Java code in my process.
    Thanks.

    I'm bit confused about what exact problem you are facing with attributes.
    You can check accessing XML attributes in BPEL Assign @ http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm#BABIHDHI from the page http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm.
    I suppose your source input has no attributes and destination has to be an xml with attribute of type xsi:type. You can use the assign activity as mentioned in above document to assign your type structure to type attribute.

  • Error : idoc xml data record : in segment attribute instead of SEGMENT

    hi all
    i am doing the file to idoc scenario. in that i am getting the error
    error : IDOC XML Data record : In segment attribute instead of SEGMENT
    i am doing this scenario since 4 days.
    can anyone help me
    thanks a lot
    Vasu

    in ref. to my post in your earlier thread.
    >>>>
    in your mapping check, in your IDOC if Begin , segment etc are mapped to a constant say '1'.
    Also ref: In segment IDOC attribute I occurred instead of SEGMENT

  • Schema Validation on attributes of an element in XML againt XSD schema

    Hi,
    I had generated artifact java classes from XSD schema file.Now i am validatiing one sample XML document by using these classes in JAXB.The XML document is validated successfully.but only elements are validated ,but not attributes of that elements.for example ,i am giving wrong element which is not defined inside the schema file,it throws validation error as expected ,whereas validation against wrong attributes of elements in XML it is not working anyway,it does not throw any validation errors,but it should throw validation errors.kindly help me to solve this issue.
    Here The sample validation code snippets :
    import javax.xml.bind.ValidationEvent;
    import javax.xml.bind.ValidationEventHandler;
    import javax.xml.bind.ValidationEventLocator;
    public class MyEventHandler implements ValidationEventHandler{
         public boolean handleEvent(ValidationEvent ve) {
              if (ve.getSeverity()==ValidationEvent.FATAL_ERROR ||
                        ve .getSeverity()==ValidationEvent.ERROR){
                   ValidationEventLocator locator = ve.getLocator();
                   //Print message from valdation event
                   System.out.println("Invalid booking document: "
                             + locator.getURL());
                   System.out.println("Error: " + ve.getMessage());
                   //Output line and column number
                   System.out.println("Error at column " +
                             locator.getColumnNumber() +
                             ", line "
                             + locator.getLineNumber());
              return true;
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    unmarshaller.setEventHandler(new MyEventHandler());

    Here is my analagous 'strange' behavior. I am jaxb processing and then marshalling generated classes to XML ( following the simple Sun 'PurchaseOrder' example )
    1. This works:
    <xsd:schema....>
    <xsd:complextType name = "myName">
    <xsd:attribute name='name1'>
    </xsd:complextType>
    </xsd:schema>
    2. This doesn't:
    <xsd:schema....>
    <xsd:complextType name = "myName">
    <xsd:attribute name='name1'/>
    <xsd:attribute name='name2'/>
    </xsd:complextType>
    </xsd:schema>
    That is, using more than one attribute line within this simple complex type causes nothing to be marshalled to XML.
    Ideas?

  • The name attribute on the img element is obsolete. Use the id attribute instead.

    When I valadate my page I get an error "The name attribute on the img element is obsolete. Use the id attribute instead." In DW CS5.5 I cannot seem to enter an ID without DW also adding the ID as a name attribute too. Aside from manually going in and removing the name attribute from the code.

    It won't hurt to leave the name attribute in your <img> tag.  In fact, it may be necessary if you are going to add an image rollover behavior, since DW's javascript relies on that name attribute's value to correctly identify the desired image on the page.

  • XML attributes and object types

    I want to create an XML Document of the following form
    <family>
    <parent attr1="val1">
    <child attr2="val2" attr3="val3"/>
    </parent>
    </family>
    Using object table and object type (for the child element), I am able to produce the following XML Document (with a "select * from family" query)
    <family> <!-- rowset -->
    <parent> <!-- row -->
    <attr1>val1</attr1>
    <child>
    <attr2>val2</attr2>
    <attr3>val3</attr3>
    </child>
    </parent>
    </family>
    The question is: how am I going to query these data so that the "attr" elements are mapped to attributes (using XSU only, without XSLT)?
    I have already tried the following:
    1. Using
    SELECT attr1 as "@attr1",
    f.child.attr2 "@attr2",
    f.child.attr3 "@attr3"
    FROM family f
    all the attributes are obviously appended to the "parent" element.
    2. Using nested table for "child" and the following query
    SELECT attr1 as "@attr1",
    CURSOR (
    SELECT n.child.attr2 as "@attr2", n.child.attr3 as "@attr3"
    FROM TABLE(f.child n)
    ) AS "child"
    FROM family f
    I am getting the following document
    <family>
    <parent attr1="val1">
    <child>
    <child_ROW attr2="val2" attr3="val3"/>
    </child>
    </parent>
    </family>
    Is there a smart SQL query to produce the desired document? What data types
    is it recommended to use to define my db schema (object types, nested tables...)?
    Thank you in advance
    null

    Finally, I got the desired XML format output from relational tablse using schema based XMLType views.
    Wherein I created Object Types from relational table, generated the schema for the Object type, registered the schema and finally created XMLType Views for populating the XML data from Relational Tables.
    I guess, you all might aware of my problem, where I got struck. Instead of printing the data in XML format I am successful in generating the XML format data Using the Query Select from BLABLA_Type_view* . I am able to print the number of rows, that I require which is in the fallowing format.
    Column Name
    1. SYS.XMLTYPE ----- As a row
    The view I am querying for is printing the data in a string format, where in I got to do the fallowing query
    SELECT SYS.XMLTYPE.getStringVal(OBJECT_VALUE) FROM BLABLA_Type_view. Which ultimately gave me the required data in XML format with tags.
    Thanks for every one who tried to give a try to solve, especially "mdrake"

  • File-Adapter: Variable substitution form payload XML-attribute

    Hi experts,
    is possible to use XML-attribute-content for variable substitution in file-Adapter?
    extract from XML:
    <?xml version="1.0" encoding="utf-8" ?>
    - <all>
    - <transaction <b>file="filename"</b>>
    - <table name="BPAADDRESS" options="insertIfUpdateFails">
    - <record id="1">
      <hkeycol name="BPAMAINHKEY">0010500345</hkeycol>
      <hkeycol name="USAGE">Invoice</hkeycol>
      </transaction>
    I want to get the value "filename" = attribute file of transaction.
    Is this possible?
    Thanks a lot,
    Florian

    I have done this taking a field from the XML.
    You have to map the location of the field within the XML...
    Taken from:
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
    Variable Substitution (Target Directory/File Name Scheme)
    If you set the Enable indicator, you can enter variables for the Target Directory and File Name Scheme. Enter the names of the variables and references in the table.
    &#9679;      Enter each variable that you reference in the Target Directory and File Name Scheme fields without the surrounding percentage sign under Name of Variables in the table.
    The variables can refer to attributes of the message header or elements of the message payload.
    &#9675;       If the variables are to refer to an attribute of the message header, add the prefix message: to the name of the variable under Reference. You can specify the following attributes of the message header:
    sender_party, sender_service, receiver_party, receiver_service, interface_name, interface_namespace,
    message_id (message ID with hyphens, for example 9fbe1ff1-9a0d-11d9-8665-cbf10a126331)
    message_id_hex (message ID in hexadecimal format, for example 9fbe1ff19a0d11d98665cbf10a126331)
    For example, if you want to specify the interface name from the message header in the target directory or in the file name scheme, enter message:interface_name as the reference.
    If one of the message attributes contains characters that are not permitted in a file name, for example \, /, :, *, ?, ", <, >, |, then these characters are replaced by an underscore ("_").
    &#9675;       If the variable refers to an element in XML schema, add the prefix payload: to the information under Reference. The reference then comprises a pseudo path description in the form of a comma-separated list with the schema namea,na,nameb,nb,....
    namea,nameb,... corresponds to the element name and na,nb,... corresponds to the occurrence of the element name at the respective level in the document.
    The description begins at the root of the document and ends at the respective element.
    To reference the element that is in bold in the example, the following expression is used: payload:root,1,e1,1,e2,2
    The parser searches for the first occurrence of the root element at the first level. It then searches for the first occurrence of e1 at the second level and for the second occurrence of e2 at the third level. The content of the last element (“Example Value”) is set as the value for a specified variable.
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
      <dummy>
         <e1>
            <e2>Data_1</e2>
            <f/>
            <g attr="abc">text</g>
            <e2>Data_2</e2>
         </e1>
      </dummy>
      <e1>
         <e2>illegal/value</e2>
         <f/>
         <g attr="abc">text</g>
         <e2 attr="fghij">Example Value</e2>
      </e1>
    </root>
    &#9679;      To disable the check the adapter performs for the element data, set the Disable Security Checks indicator.
    Otherwise, the adapter checks whether the element data contains characters that could lead to security risks in the file system environment. The check includes the characters “/“, “\“, and “..“.

  • Text Box issue - displays XML tag instead of the value in EBS

    I need to use a textbox (or a autoshape with text) to place a data element in a specific position on the page in an RTF template. I tried using tables and it didn't help. This layout needs some elements to be placed at specific location and using an autoshape or a text box is easy. When I preview the pdf output on my desktop, it works fine. Once I upload the template into EBS XML Publisher, the value in the text box shows up as an XML Tag instead of the value in that tag. The same XML data when loaded and previewed locally shows the data instead of the tag.
    Any thoughts on this? Is there a patch or something we might need for this in EBS?
    Thanks,
    Vinay

    Thanks Tim for the quick response.
    Yes - the versions are same. Also, I tried giving the complete path. The issue is that it is not even reading the text in the text box as an XML tag. It seems to think the whole text box is an object and hence just display that text as is. If it was reading and not able to resolve it, I guess it would have displayed blank (and not the tag as is). Again as I mentioned it works fine in local preview on my machine.

  • Using BPEL console testing with XML attributes

    I'm having trouble with using an XML attribute in my BPEL process. When I put an attribute on my input element, the BPEL Console test page no longer works. Here's what I'm doing:
    I create a synchronous new BPEL project in JDeveloper using the default input and output XSDs, and add a simple assign to assign the input to the output. When I deploy this and look at it in BPEL console, I can see the input field and enter my value to test.
    Now I go back into JDeveloper and add an attribute to the input element, and then redeploy my process. Now when I go into BPEL console, the Initiate tab no longer has any field for me to enter my value. Clicking the XML Source radio button doesn't help either. (I also tried invoking the BPEL process web service through the app server control - same issue.)
    I'm using JDeveloper 10.1.3.3 with App Server 10.1.3.3.0. Does anyone know how to make the BPEL Console testing work with XSDs that contain attributes?
    Thanks,
    Skip

    A bit more info on this. It doesn't appear that the problem is limited to the console tester. I created another BPEL process which calls my original process, and attempted to set the attribute on the input using the Assign activity. JDeveloper generated this:
    <assign name="Assign_1">
    <copy>
    <from variable="inputVariable" part="payload"
    query="/client:TestAttributes2ProcessRequest/client:input"/>
    <to variable="Invoke_1_process_InputVariable" part="payload"
    query="/ns1:TestAttributesProcessRequest/ns1:input"/>
    </copy>
    <copy>
    <from expression="'bob'"/>
    <to variable="Invoke_1_process_InputVariable" part="payload"
    query="/ns1:TestAttributesProcessRequest/ns1:input/@attribute1"/>
    </copy>
    </assign>
    As you can see this is mapping a variable into the /TestAttributesProcessRequest/input element and then attempting to set the attribute of that element to the value 'bob'. This compiles just fine but when this code is executed, this error occurs:
    Error in <assign> expression: <to> value is empty at line "87". The XPath expression : "" returns zero node, when applied to document shown below:
    oracle.xml.parser.v2.XMLElement@7efe7efe
    (Line 87 is query="/ns1:TestAttributesProcessRequest/ns1:input/@attribute1"/>)
    Is there something wrong with this generated code? Do I need to do some kind of custom code to set attributes, instead of using the graphical tools in JDeveloper?

  • Database control does not map to an XML attribute

    Hi
    Im trying to execute a stored procedure that would return me an XMLBean. During this process, the database control returns me an XMLBean, but doesnt map the XML attributes if any contained in the XSD. All data is mapped to the elements only. Kindly let me if anyone knows how to resolve this to map to the attributes.
    Thanks
    Kishore

    Hi
    Im trying to execute a stored procedure that would return me an XMLBean. During this process, the database control returns me an XMLBean, but doesnt map the XML attributes if any contained in the XSD. All data is mapped to the elements only. Kindly let me if anyone knows how to resolve this to map to the attributes.
    Thanks
    Kishore

  • XML Attributes Created Twice in the XML after Saving in FM

    Hi All,
    I've built a structured application to read and write a custom XML. The file is opened just fine. However, when saving the XML in FM, some XML attributes appear in the XML twice. For example, in the original XML I have the following:
    <object_group doc_name="xxx" parsed_by_sym="false">
    </object_group>
    After I save the XML, it looks like this:
    <object_group doc_name="xxx" parsed_by_sym="false" doc_name="xxx" parsed_by_sym="false">
    </object_group>
    After the XML is saved, FM refuses to re-open it aborting the parsing. If I remove the doubled attributes manually in Notepad, then the XML is opened in FM again.
    Should I define anything in read/write rules? What am I doing wrong?
    I'm using an XSD, which I defined in structapp.fm.
    Thank you very much!

    Alex,
      Without looking at the application and document, I don't have any other ideas. To debug a situation like this, I would try variations such as the following, investigating any change that eliminates the doubled attribute:
    1) If you haven't already, shut your computer down and restart it.
    2) If the application uses a custom client or processing, remove them. If their absence makes a difference, the problem may originate in them.
    3) Simplify the test document as much as possible, probably in several steps. For example, remove all optional attributes and elements. Remove all non-containers (tables, xrefs, graphics, etc.) You may need to change the EDD or schema to create as short a document as you can that fails. The goal is to have a document with just a few elements and only one attribute that fails.
    4) Change the element and attribute names, which shouldn't make a difference, but may be worth testing.
    5) Simplify or eliminate the r/w rules.
    6) Simplify the EDD so that the only defined elements and attributes are the ones that appear in the small sample.
    7) Remove all format rules and autoinsertions from the EDD. The goal is to remove anything that should not be relevant.
    8) Simplify the schema in the same way.
    9) Remove the schema from the application. If doing so eliminates the duplicate, convert the schema to a DTD and see if using a DTD instead of the schema makes a difference.
    10) Make sure your have installed all updates to the version of FM you are using.
    11) If you have access to a different version of FM, see if it behaves the same way.
    Good luck and let us know when you find the problem.
         --Lynne

  • ASSIGN VALUE TO XML ATTRIBUTE DYNAMICALLY

    how can we create and asign value to an XML attribute dynamically?

    Hi Harshit,
    In this case you should use append xml instead of assign in the assignment action block.
    Assigfn values to local variables from sql query say "Local.Shift", "Local.Quantity" and "Local.Total" then append it to your output as:
    <root  Shift="#Local.Shift#" Qty="#Local.Quantity#" Total="#Local.Total#" />
    Append it to parent of <root /> element.
    Regards,
    Swaroop

  • Format String using XML attributes

    I need to format a string based on attributes from a schema. I am attempting to do this using an Assign activity and the java embedded format string function. Here is a simplified version of what I am trying to do:
    oraext:format-string('Service Error COD={0}', bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD'))
    When I execute this line I get:
    XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is oraext:format-string('Service Error COD={0} ',bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD')). The XPath expression failed to execute;
    The value at bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD' is valid because I can create a dummy xsd:string variable and set it equal to that.
    I also tried to wrap the getVariableData with the get_content_as_string methods and neither worked. I also verified that my format-string function is working because when I substitute just a plain string like ‘T01’ the string is successfully created.
    Any ideas what I am doing wrong or how I can accomplish this?

    If the xml document is to be stored in the Oracle database with the XML SQL Utility, defne elements instead of attributes. XSU utility does not map the attributes of an xml document to the database table.
    Further ref:
    http://xml.coverpages.org/elementsAndAttrs.html

  • Related to XML attributes

    now my xml.dtd file has the structure like this
    <!ATTLIST nete:forward
    filter CDATA #IMPLIED>
    that means that <nete:forward>element should contain one attribute....only....so in .xml file i can specify like<nete:forward filter="myfilter">........</nete:forward>
    now the requirement is ..it should support multiple attributes(infinite).......
    So instead of hard coding the dtd file like
    <!ATTLIST nete:forward
    filter CDATA #IMPLIED
    filter1 CDATA #IMPLIED
    filter2 CDATA #IMPLIED..........>
    .......Is there any way to specify ....to have multiple attributes for a element
    like
    <!ATTLIST nete:forward
    filter* CDATA #IMPLIED>
    so my final requirement is customer can add as many attributes he want like
    <nete:forward filter="xxx" filter1="yyy" filter2='zzz"........so on........</nete:forward>
    i think question is clear..........?

    I would expect element <nete:forward> to contain a set of <filter> elements rather than a set of filter attributes.

  • Set XML attribute from SetValue using Xpath

    Is there a trick to assigning a value to an attribute of an element in an XML variable using XPATH inside a setValue activity?  When I try something like
    Location
    /process_var/xml_var/test/@ID
    Expression:
    /process_var/test_value
    it complains about the @ sign in the location assignment.  I seem to be able to retrieve attributes just fine.

    Still having this issue.
    If I have an XML process variable which currently contains
    <Document>
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it fails.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    Try this, it works.
    Location: /process_data/xml/Document/ID
    Expression: 54
    Now, alter the XML by adding an ID attribute
    <Document ID="">
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it works, where it failed earlier.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    It appears to me, you can ADD a new node, but you can't ADD an attribute

Maybe you are looking for

  • How to change the color (or fill) of a SINGLE bar in a bar chart series

    I've searched the forum and consulted the help system in Keynote '09, and I can't find the answer. I have a simple bar chart with 6 bars. I want to select two of the bars and turn them a different color. I only seem to be able to change the color of

  • Login to Oracle 8i Server from a remote location.

    Hi Experts, I wish to connect to Oracle 8i Server at Site 1 from Site 2. Situation Site 1     -     Oracle 8i on Win 2K. This is behind a firewall FW1. Is in Win NT Domain1. Site 2     -     Oracle 8i Client on Win 98. This is also behind (a separate

  • Where is the file with sms

    I made a manual backup of my mem card - were is the sms located, if i want to move them back to my card ?

  • Vendor list as per last purchase price!

    I need a query to display all vendors  as per last purchase price. Thanks...

  • SATA RAID Controller under Solaris 10

    I want to set up my Sun Ultra AXMP on a SATA RAID5, but i did not find yet a controller wich is supported by Solaris 10. I already looked for support on the Adaptec 2410SA and all other Adaptec Controlleres (searched here: http://www.sun.com/bigadmin