Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am writing a simple WCF service. Below is the few lines from the wsdl created.

<s:Envelope xmlns:s="">
    <Action s:mustUnderstand="1" xmlns=""></Action>
    <Open xmlns="">
      <header xmlns:d4p1="" xmlns:i="">
        <d4p1:dstApplicationID i:nil="true" />
        <d4p1:messageID i:nil="true" />
        <d4p1:srcApplicationID i:nil="true" />
      <calldata xmlns:d4p1="" xmlns:i="">
        <d4p1:Item i:nil="true" />
        <d4p1:Organisation i:nil="true" />
        <d4p1:Solution i:nil="true" />
        <d4p1:Source i:nil="true" />
        <d4p1:additionalAttribute i:nil="true" />
        <d4p1:agent i:nil="true" />

in each tag there is this "<d4p1:" getting added, i want to replace it with "ajt". How do i do it and from where is this tag getting added?
Rakhesh Rajan 12-Jun-13 10:14am    
I have observed if i mention namespace as "" in the datacontract lik [DataContract(Namespace="")] then the prefix tag "

1 solution

You can easily do it if you write the file by yourself. Really easily. If you really need it, I can find out and explain it; I really do it in my work, probably for the same purpose as you do: better readability for a human, via adding semantically sensible prefix.

However, I bet you don't do it by yourself: the Data Contract does it for you, more exactly, DataContractSerializer:[^].

And, as far as I know, you don't have control over the prefix. It affects nothing at all (try to replace it with any valid unique XML name and you will see that same software parses the file/stream exactly the same way), so it is not an option.

Generally, one little problem with this serializer is: it is not so laconic and so human-readable as you probably would like it to be. Do you want to know what's my solution? I'm working for alternative version of the serializer used to replace the one from Microsoft; the first version is already deployed to customers. But this is really, really hard job. As System.Reflection.Emit is used (otherwise performance would be too bad, I know that from my old version of similar technology I invented when Data Contact was not yes available from Microsoft), it is really hard to debug and requires good knowledge of CIL. I'm not sure you want to bite a bullet just for fixing a small prefix.

Share this answer
Rakhesh Rajan 13-Jun-13 5:59am    
Thanks Sergey
Sergey Alexandrovich Kryukov 13-Jun-13 11:54am    
You are very welcome.
Good luck, call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900