building a client for WCF (.net 3.5): Please check my approach below and tell me if I am I on the right track


I'm building a client to connect with the Monster web-service (

I opened up VS2008 and added the "Service Reference" to my project, specifying the link:

VS2008 created the following Reference.cs (attached).

So, inspecting the proxy code (all 45k lines!) I can see the proxy interface is: BusinessGatewayInterface, and the class that impements that is BusinessGatewayInterfaceClient. So I need to create one of these client objects and call my methods.

So which method? I want to add/update a job, so, I'm guessing the WebMethod I need to call is UpdateJob().

However the public one has these complex parameters:

        public VacancyManager.WSMonster.JobsResponse UpdateJob(
ref VacancyManager.WSMonster.MonsterHeader MonsterHeader,
VacancyManager.WSMonster.CompanyAuthHeader CompanyAuthHeader,
VacancyManager.WSMonster.Security Security,
VacancyManager.WSMonster.Security1 Security1,
VacancyManager.WSMonster.Security2 Security2,
VacancyManager.WSMonster.Job Job)

Searching for the definitions of the object:
So in my client code I need to create all of these, initialise their members, and then pass them to UpdateJob?

Wow, a lot of work... and no documentation....

(hint, don't waste time as I did searching for "class VacancyManager.WSMonster.Job", search for "class Job" as they're all nested classes!)

So I guess I set all the public properties (*or*... as many as I can... I suppose the WSDL would tell me which are optional and which are mandatory, if I could understand it lol) of each of these parameter objects.

NB some of the properties are not simple types but references to *other* objects which will need to be created and initialised...

and then the response will have to be parsed into objects as per the class hierarchy / composition tree.

All ye experienced WCF people: Am I on the right track with all this?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Prakash SamariyaIT ProfessionalCommented:
Please check the steps to consume WCF service

Complete guide about WCF Service:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zorba111Author Commented:
Hi Prakash, thanks for these. The first link was a bit basic, but I'm reading the second one and getting some insights.
zorba111Author Commented:
Ok, so today I've created all the objects and sub-objects (and sub-sub-objects lol) I think I need for the parameters. I've been getting exceptions on calling the method, progressing through these messages:

> System.ServiceModel.FaultException was unhandled
  Message="Client not authenticated after processing available headers."

So I checked the credentials and then I got this one....

> System.ServiceModel.FaultException was unhandled
  Message="Bad Request"

a few more tweaks...

> System.ServiceModel.FaultException was unhandled
  Message="Client request failed validation,error=cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'."

a few more tweaks, removing optional fields...
and finishing up with

>  Error in deserializing body of reply message for operation 'UpdateJob'.

which is where I'm stuck right now..
I can see from google a lot of people have had this last exception!
zorba111Author Commented:
So I increased the quotas under the binding configuration in app.config, as per this

like so...

<readerQuotas maxDepth="999999" maxStringContentLength="999999" maxArrayLength="999999"
    maxBytesPerRead="999999" maxNameTableCharCount="999999" />

Open in new window

And that has stopped the last "serialization" exception happening. In fact the WCF method now executes without exceptions!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.