Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

WCF service method return error when all property values are not provided on call

$
0
0

Dear all,

i am writing a wcf service method that is used to update an existing record. the table that will update in the database contain around 60 fields. the user want to pass only the properties (with values) that need to update through this service method. i wrote this wcf service in c# but the client may use it with any platform they want so the request and response needs to be in xml [a requirement].

as parameter i have defined a class representing the table fields, each field have

isrequired=false,

emitdefaultvalue=false

now i am using soapui to test this service call; as follow:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:brm="http://schemas.datacontract.org/2004/07/BRM.BusinessEntities"><soapenv:Header/><soapenv:Body><tem:Update><!--Optional:--><tem:entity><brm:Name>1</brm:Name><brm:age>42</brm:age><brm:CustomerType>605</brm:CustomerType><brm:address>abc</brm:address></tem:entity></tem:Update></soapenv:Body></soapenv:Envelope>

and receiving the following error.

The formatter threw an exception while trying to deserialize the message:

*) when i pass three or four parameters that are defined in the class right after each other then record is updated successfully [when the fields are defined from top to bottom order]

*) when i pass parameters that are defined in the class with random order (not up to down) then the same error is shown.

what i want :

1) is there a way to pass parameters (in any no. like 2,3,4 etc) (defined anywhrere in the class) such that wcf service could accept it and then record is updated easily after execution

possibilities :

1) do i have to pass all parameter values; (if some value is not require to change then pass any specific / default value and process in the service such that it dont require any change) like pass null for string and in service apply an if statement that if value is null then it does not require to change anymore

please suggest me the right way

with many thanks


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>