Adapter Class is necessary ?

Topics: General Discussion Forum, July and December Releases Forum
Feb 13, 2008 at 7:30 AM
Can anybody please clear my doubts, i am confused with so many things...

Here is my doubts....

1. To insert some thing like Customer Details, ino the DB,
Is it necessary that we have to create an AdapterClass.

2. suppose PutCustomerResponse is Message type/Contract,
then What will be the member of that MessageContract ? Can it be the Same Members of Data Contract.

3. Let AddCustomer is a Service Operation, While Creating it through the wizard i am supposed to give a response type and
request type, What should i give as response type and Request type ? The Response type is similar to return type or not...

4. For each service whether we have to create seperate Response,request and Adapter.

Thanks and Regards,
Nimesh Prabhakar

Feb 13, 2008 at 2:20 PM
Howdy Nimesh,
I did not design this software and these are only my opinions and observations. So, with that disclaimer out of the way, lets get into your issues.
1. To insert something into the DB, you should look into the Repository Factory. That will do a lot of the heavy lifting for you.
2. This question may need a little more clarification. Do you expect PutCustomerResponse to be the resulting message after an operation completes, or will PutCustomerResponse be the initiating message? Also, is PutCustomerResponse to put the customer in the database, or is it to fill out a customer info object from the database?
3. If AddCustomer is a service operation, request type can be overloaded. One may pass in a "Customer" object that you defined in your data contract, and another can have the individual values passed in separately as primitive data types. As for the response, it is usually good form to return the primary key of the record added to the database.
4. Yes, for each service operation, you will most likely have to create a separate Response and Request, at least that is how I have been doing it. As far as the Adapter goes, see answer to question 1.

I hope this helps a bit.
Feb 13, 2008 at 3:03 PM

Yeah it helped me a bit, but again i am having a bunch of doubts..

From where can i find the Repository Factory ?

PutCustomerResponse is the one to be a resulting message after an operation..
For eg : like it should be the return type, that is after the opeartion of RegisterCustomer, if the operation is sucess then it returns true. if the operation fails or customer exists, then it should return false...
This is my Purpose, in that case what can i do ?

PutCustomerRequest and PutCustomerResponse are the two message types that i am goign to use.
so in that case, instead of giving the primitive datatype as the return type can i give PutCustomerResponse..Is it Correct ?

Note one point:: i have created PutCustomerRequest and PutCustomerResoponse as the Message Contracts.
PutCustomerRequest contains the Members same as DataContract has, and PutCustomerResponse has a member called sucess with the Primitive datatype boolean.

So for a service there can be only one Request and Response or more than one, i want clarification for that too.

If you could help me, it would be of great help...

Thanks and Regards,
nimesh Prabhakar

Feb 13, 2008 at 3:38 PM
If you want to use the repository factory, simply search for "Repository Factory" on codeplex. Repository Factory has its own project here. It was originally part of the Service Factory before the Modeling Edition came out, but people saw a need for Repository Factory outside of only the Service Factory so they broke it out, which was VERY smart. Unfortunately, they did not re-incorporate the Repository factory back into Service Factory when Repository factory was finished and reading many of the how-to's, you are expected to know that Repository Factory exists and how you are to incorporate the two together. I don't consider this an oversight, since each project wants to explain how to use their software, but I think a detailed explanation of how to use them together would be nice. David Hayden goes into this quite a bit, but I still found some gaps, so I created a document and project demonstrating how to combine Web Client Software Factory (WCSF), Web Service Software Factory (WSSF), and Repository Factory (RF). I have not posted them to the public yet, only to an intranet knowledge base where I work. I am hoping to post these soon though for the world to see.

Your thoughts on PutCustomerRequest are right on the mark. Your thought pattern regarding this solution are the same as mine. Your service should return the "PutCustomerResponse" and the consumer should look at the boolean member "PutSucess" or whatever you call it.
I have been using the WCF implementations and tools in Visual Studio, which allow me to add a "Service Reference" and call the web service through a proxy and this proxy will return an object of the datatype I am looking for, not the MessageContract. The WCF tools in Visual Studio will wrap the message contract and do the calling for you, you simply use the proxy as if it is a local object and it behaves as if it is a local object, not a web service.

The consumer will look similar to:
CustomerServiceContractClient proxy = new CustomerServiceContractClient();
bool success = false;
success = proxy.RegisterCustomer(CustomerObject);
if( proxy.State == System.ServiceModel.CommunicationState.Opened )

if( success )
System.Console.Writeline("Yeah Me!");

Of course A LOT of the instructions to get a fully service running is left out, but I hope you get the idea.

As far as your question for only one Request and Response goes, I am not sure. I only use one of each for my services. Don't forget though, that there is also the Fault that may be thrown as well.

Hope that helps.
Feb 13, 2008 at 3:54 PM
Thanks a lot for the valuable instructions and Guidance,
i created a service, adn when i debug client or runclient i am receving an exception like this :

"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs. "

I changed the web config file as

<serviceDebug includeExceptionDetailInFaults="true" />

after that when i debugg i am receving another error...

Fault Exception `1 was handled
"The method or operation is not implemented."

But when i am viewing this in the browser, iam getting an error like;;;

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

                            • Exception Text **************
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)

Exception rethrown at 0:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Close()
at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose()
at Product.Tool.Client.MainForm.ExecuteButton_Click(Object sender, EventArgs e) in C:\PCT\First\Product.Tool\Tests\Product.Tool.Client\MainForm.cs:line 42
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

                            • Loaded Assemblies **************
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
Assembly Version:
Win32 Version:
CodeBase: file:///C:/PCT/First/Product.Tool/Tests/Product.Tool.Client/bin/Debug/Product.Tool.Client.exe
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Windows.Forms/
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System/
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Drawing/
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Configuration/
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Xml/
Assembly Version:
Win32 Version: 3.0.4506.30 (WAPRTM.004506-0030)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.ServiceModel/
Assembly Version:
Win32 Version: 3.0.4506.30 (WAPRTM.004506-0030)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/SMDiagnostics/
Assembly Version:
Win32 Version: 3.0.4506.30 (WAPRTM.004506-0030)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Runtime.Serialization/
Assembly Version:
Win32 Version: 3.0.4506.30 (WAPRTM.004506-0030)
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.IdentityModel/
Assembly Version:
Win32 Version: 3.0.4506.30
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.IdentityModel.Selectors/
Assembly Version:
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC32/System.Transactions/

                            • JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the section.
The application must also be compiled with debugging

For example:

< jitDebugging="true" />

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Do you have any suggestion for this,

Thanks and Regards,

Feb 13, 2008 at 4:09 PM
Right, here is my first guess.
The first thing that jumps out at me is the "The method or operation is not implemented." statement. To me that suggests that you have not overridden your service function. In your ServiceImplementation project, you should have a folder named "GeneratedCode". Inside this folder you should have a file like "CustomerService.cs" or something like it. This is the code generated for you from the Modeling artifacts. YOU will have to create a partial class that overrides the defined methods. Within these methods that you write yourself, you will do the business logic, or have the business logic done for you in the business logic project.
Feb 13, 2008 at 5:04 PM

You can get the Repository Factory from here:
Regarding the Adapter question, that class will basically perform the validation of the Request/Response message and the translation between DC and BE using the translators classes generated with the package.
On the other hand, you don't need to have all the same properties in your MC as your DC, you can simple point the DC inside the MC and have all the data defined in DC in order to get the practical value of them as "resusable types". At the same time, remember that DCs are also used for sharing types in the contract and decouple your business layer from the service consumer so your BEs will live only inside your business layer or business domain.

Feb 14, 2008 at 7:38 AM
Hi CF,
i could solve all those errrors, and now i am facing the problem in the adapter class. Its all about the translation of datacontract to bussiness contract.
How can we code manually in the adapter class to translate BE from DC ?

I would like to get one more clarification about he wssf .
I am usign wssf dec 2006 release, in that case is it necessaryt hat we hav eto get repository factory,
Does the wssf december 2006 release contains repository factory.
Feb 14, 2008 at 2:13 PM
Yes, that version contains the RF formerly known as "Data Access Guidance Package".
Regarding your translators issue, I posted and answer here: