Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional WCF 4: Windows Communication Foundation with .NET 4
This is the forum to discuss the Wrox book Professional WCF 4: Windows Communication Foundation with .NET 4 by Pablo Cibraro, Kurt Claeys, Fabio Cozzolino, Johann Grabner; ISBN: 978-0-470-56314-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional WCF 4: Windows Communication Foundation with .NET 4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
View Poll Results: This is a common Problem that people encounter?
Yes, I understand where you are coming from. 1 100.00%
No, you are silly by not getting this simple concept. 0 0%
Voters: 1. You may not vote on this poll

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 24th, 2010, 09:21 AM
Registered User
 
Join Date: Dec 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Generating Client Code

I am stuck on Step 4 on page 42 (Chpt.2) It says to use the svcutil or the reference service option to generate the client code. But, I ran the svcutil in the previous step and generated the three files, but what do I do with them now? It doesnt state how exactly one uses these files to generate the proxy for the client. I am stumped. Please help!!!

BTW, I created a new project for the client (seperate from the service class). Also in the figure 2.6 Client Code where is this assembly:

using Wrox.CarRentalService.ConsoleClient.CarRentalProxy ;

It never mentions creating this assembly anywhere in the book. But now it says to reference it? Whats in this file and how does it relate to the client code. Tried for 2 days trying to figure this out. PLEASE HELP!! Thank you in advanced. Have a merry xmas and happy holidays all.
-Argbyle Ghost
Reply With Quote
  #2 (permalink)  
Old December 24th, 2010, 02:06 PM
Registered User
 
Join Date: Jun 2010
Posts: 5
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Argbyle Ghost,

the svcutil.exe command line generate a source code file and a config file. Then, you can include them in your project and use to call the remote service:

1. Use svcutil to generate files. Example: svcutil.exe <wsdl> /n:*,Wrox.CarRentalService.ConsoleClient.CarRentalP roxy
2. Include the generate .cs and merge the .config with the project's .config (web.config or app.config)
3. Use the proxy :)

HTH
Fabio
Reply With Quote
  #3 (permalink)  
Old December 24th, 2010, 11:10 PM
Registered User
 
Join Date: Dec 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks, but still having issues with this.

Thanks for the quick reply Fabio. unfortunately I still can not get (more like understand what is going on) it to work. a little backround. I have 2 projects:
1. CarRentalService (Which contains the ICarRental interface and the class that incorporates the interface for the inner workings,)
2. CarRentalClientConsole. This is the client Which will call the service.

from the VS command prompt running as administrator I ran:
C:\inetpub\wwwroot\CarRentalService\CarRentalServi ce\bin>svcutil.exe CarService.wsdl /n:*,Wrox.CarRentalService.ConsoleClient.CarRentalP roxy

(There is already three files from running the svcutil.exe from earlier that I renamed (not the extension)in this directory to CarService.wsdl, CarService.xsd, and I kept the file named the same for schema.microsoft.com.2003.10.Serialization.xsd)

and I recieved the following error:
Code:

c:\inetpub\wwwroot\CarRentalService\CarRentalService\bin>svcutil.exe CarService.wsdl /n:*,Wrox.CarRentalService.ConsoleClient.CarR
entalProxy
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation.  All rights reserved.

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessa
geContractImporter
Error: Schema with target namespace 'http://localhost:8080/' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://localhost:8080/']/wsdl:portType[@name='ICarRentalService']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://localhost:8080/']/wsdl:portType[@name='ICarRentalService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://localhost:8080/']/wsdl:binding[@name='DefaultBinding_ICarRental
Service']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servi
ces
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata docum
ents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
What am I missing here? I am new to WCF Services and I am quite confused as to what I am doing wrong ...and how to fix.
I hope the code helps you see where I might be going wrong.
Merry xmas,
Argyle Ghost
Reply With Quote
  #4 (permalink)  
Old December 28th, 2010, 06:52 AM
Registered User
 
Join Date: Dec 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Still need help

Still need help .... Anyone.... anyone.....
Reply With Quote
  #5 (permalink)  
Old December 28th, 2010, 07:49 AM
Registered User
 
Join Date: Jun 2010
Posts: 5
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Argbyle Ghost,

sorry for the late response. Try this:

svcutil.exe *.wsdl *.xsd /n:*,Wrox.CarRentalService.ConsoleClient.CarRentalP roxy

HTH
Reply With Quote
The Following User Says Thank You to Fabio.Cozzolino For This Useful Post:
argyleghost (December 28th, 2010)
  #6 (permalink)  
Old December 28th, 2010, 07:36 PM
Registered User
 
Join Date: Dec 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default OK, getting closer... :D

Thanks for the replies and help Fabio.
I just deleted the 3 previous files that were generated from the bin folder. ran the svcutil.exe on the Contracts.dll and it generated the three files again.

I then took your last code and generated the two files (Schema.cs and the output.config). Looking in the schema.cs I saw that there is a namesspace:
Code:
namespace Wrox.CarRentalService.ConsoleClient.CarRentalProxy
{
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="Wrox.CarRentalService.ConsoleClient.CarRentalProxy.ICarRentalService")]
    public interface ICarRentalService
    {
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICarRentalService/CalculatePrice", ReplyAction="http://tempuri.org/ICarRentalService/CalculatePriceResponse")]
        double CalculatePrice(System.DateTime pickupDate, System.DateTime returnDate, string pickupLocation, string vehiclePreference);
    }
two things now (which are not explained at all in the book).
1. [QUESTION] How did it know in the namespace to put "...consoleclient.CarRentalProxy"? I checked for code all over the Carservice app and there is nothing there referencing such client. I have the ClientConsole in a totally seperate solution. How did it know?

2. [WHAT I DID - WAS IT THE RIGHT WAY?] I created an app.config in the client Console app and copied and pasted the "output.config" in it. Then I created an ICarRentalService.cs file in the Console Client and copy and pasted the schema.cs file there.


Ran the code and the console did come up (finally! Thanks Fabio!). I did run into an Invalid Operation Exception error: "The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified."

But at least the console started to run. Wrox really needs to update this section of the book. It scares me what assumptions they left for the other 900 pages. :D
Reply With Quote
  #7 (permalink)  
Old December 29th, 2010, 08:42 AM
Registered User
 
Join Date: Dec 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default duh!

I see it got the name from the svcutil command. Hehehehe, thanks. It just dawned on me.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 17th, 2005 11:53 PM
Client Side JavaScript Generating HTML Files interrupt Javascript How-To 1 January 14th, 2005 10:36 AM
error in snapshot generating code (asp) vinodkalpaka Classic ASP Components 2 July 20th, 2004 01:14 AM
error in snapshot generating code (asp) vinodkalpaka Pro VB 6 0 July 19th, 2004 01:19 AM



All times are GMT -4. The time now is 09:04 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.