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:
Hi,

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

XML
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IEhelplineService/Open</Action>
  </s:Header>
  <s:Body>
    <Open xmlns="http://tempuri.org/">
      <header xmlns:d4p1="http://schemas.datacontract.org/2004/07/eHelplineESBService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <d4p1:dstApplicationID i:nil="true" />
        <d4p1:messageID i:nil="true" />
        <d4p1:srcApplicationID i:nil="true" />
      </header>
      <calldata xmlns:d4p1="http://schemas.datacontract.org/2004/07/eHelplineESBService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <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?
Posted
Comments
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:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx[^].

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.

—SA
 
Share this answer
 
v3
Comments
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.
—SA

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