c# - WCF service + SvcUtil generating unexpected object structure -


i trying create wcf application listen requests suppliers system. supplier has provided me wsdl need create service , expose its' endpoint them.

i have used svcutil.exe generate c# classes, outputs rather odd-looking types.

this snippet of wsdl has been given me:

<?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textmatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">   <wsdl:types>     <s:schema elementformdefault="qualified">       <s:element name="submit">         <s:complextype>           <s:sequence>             <s:element minoccurs="0" maxoccurs="1" name="incident">               <s:complextype>                 <s:sequence>                   <s:element minoccurs="0" maxoccurs="1" form="unqualified" name="transactionid" type="s:string" />                   <s:element minoccurs="0" maxoccurs="1" form="unqualified" name="transactiontype" type="s:string" />                   <s:element minoccurs="0" maxoccurs="1" form="unqualified" name="transactionsubtype" type="s:string" />                   <s:element minoccurs="0" maxoccurs="unbounded" form="unqualified" name="configurationitem">                     <s:complextype>                       <s:sequence>                         <s:element minoccurs="0" maxoccurs="1" form="unqualified" name="assettag" type="s:string" />                         <s:element minoccurs="0" maxoccurs="1" form="unqualified" name="name" type="s:string" />                     .... 

the command run simply

svcutil.exe file_name.wsdl 

i expect creates structure this:

class submit { ... } class incident { ... } class configurationitem { ... } 

so when serialized like:

<submit>     <incident>         <transactionid>12345</transactionid>         <transactiontype>12345</transactiontype>         <transactionsubtype>12345</transactionsubtype>         <configurationitem>             <assettag>xyz</assettag>             <name>name</name>         </configurationitem>     </incident> </submit> 

however, output of svcutil.exe gives me following:

class submitincident { ... } class submitincidentconfigurationitem { ... } 

it's seems bunch submit , incident objects one, , prepends 'submitincident' onto each of nested elements. when serializing this:

<submitincident>     <transactionid>...</transactionid>     <transactiontype>...</transactiontype>     <transactionsubtype>...</transactionsubtype>     <submitincidentconfigurationitem>         <assettag>...</assettag>         <name>...</name>     </submitincidentconfigurationitem> </submitincident> 

this causes problems both supplier (my service doesn't match wsdl can't talk me), , onward processing doing in application. can me understand why happening, how stop it, , svcutil output properly.

it turns out class definitions , definitions aren't issue here (it cause problem later that's resolvable once understand what's going on). issue rooted in had done in throwaway-development phase.

the first thing did use svcutil.exe generate server classes using wsdl supplier. once had enough start debugging/testing, naturally headed wcf test client , visual studio's built in development server. when using client, kept coming sorts of obscure errors, e.g. https not supported, problems contracts , bindings, etc. many of them configuration inconsistencies fixed bit of googling, amongst errors this:

the operation not supported in wcf test client because uses type submitincident

this happening when of submitincident's properties of type object (even if nested lower down in other properties). working on 1 error @ time, pulling out bits didn't work until did. mainly adding , removing attributes on properties , classes, e.g. datamember,soapaction, namespace, etc.

eventually able invoke endpoints in application using wcf test client. when came other applications communicating it, failing per original question. changes made working in wcf test client made service invalid original wsdl schema!

tl;dr;

do not build wcf applications using wcf test client test them. can't stress enough. forces remove things cause application break in normal use. use industry standard application soapui development phase.

useful links


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -