xml - Supply a different namespace for a DataMember in a WCF DataContract -


this example of vb class 1 of data data contracts:

<system.codedom.compiler.generatedcodeattribute("xsd", "2.0.50727.3038"), _  system.serializableattribute(), _  system.diagnostics.debuggerstepthroughattribute(), _  system.componentmodel.designercategoryattribute("code"), _  system.xml.serialization.xmltypeattribute([namespace]:="http://www.example.com/ns1"), _  system.runtime.serialization.datacontractattribute([namespace]:="http://www.example.com/ns1")> _ partial public class sometype     ...     private somememberfield string     ...       <datamember(order:=4)> _     public property somemember() string                     return me.somememberfield         end         set(value string)             me.somememberfield = value         end set     end property end class 

wsdl becomes (namespace http://www.example.com/ns1 expected):

<xs:complextype name="sometype">   <xs:sequence>     ...     <xs:element minoccurs="0" name="somemember" nillable="true" type="xs:string"/>     ...   </xs:sequence> </xs:complextype> 

a xml example is:

<sometype xmlns="htttp://www.example.com/ns1">    ...    <somemember>some text</somemember>    ... </sometype> 

this perfect me. client (which not wcf) needs different namespace datamember. xml example this:

<sometype xmlns="http://www.example.com/ns1">    ...    <somemember xmlns="http://www.example.com/ns2">some text</somemember>    ... </sometype> 

i believe wsdl should similar this:

<xs:complextype name="sometype">   <xs:sequence>     ...     <xs:element minoccurs="0" name="somemember" nillable="true" type="xs:string" xmlns:q1="http://www.example.com/ns2"/>     ...   </xs:sequence> </xs:complextype> 

i know how complex data types.

all have change namespace in datacontractattribute of respective class, did members aren't primitive data types.

is possible primitive data types such string?

i can't change namespaces in datamembers , can't figure out other way of setting different namespace primitive data type.

however, xml examples generated xsd include namespaces in primitive data type members.

does know how can using wcf?

<sometype xmlns="http://www.example.com/ns1">    ...    <somemember xmlns="http://www.example.com/ns2">some text</somemember>    ... </sometype> 

thanks in advance,

fernando martins.

solution found!

using service contract this:

<servicecontract(namespace:="http://www.example.com/ns1")> public interface myservicecontract     ...  end interface 

xml class sometype looks this:

<sometype xmlns="htttp://www.example.com/ns1">    ...    <somemember>some text</somemember>    ... </sometype> 

adding xmlserializerformat() service contract:

<servicecontract(namespace:="http://www.example.com/ns1")> <xmlserializerformat()> public interface myservicecontract     ...  end interface 

xml becomes (namespaces displayed each member):

<sometype>    ...    <somemember xmlns="htttp://www.example.com/ns1">some text</somemember>    ... </sometype> 

then, third-party client assigns sometype same namespace sometype encapsulated.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -