Tuesday, September 29, 2009

Lab #7: Controlling Message Serialization with Message Contracts

Members:
Rafael Zuniga, Stephen Cave

Summary:
First we implement save and get gig requests and responses in a new class messages for the gigManager project.

Updated functions savegig and getgig.

Next we create a proxy for the client, running host and adding a service reference. Code is added to GigInfoForm.cs and the buttons are completed, compiling and running without error.

Changing the header value passed results in an exception as intended by the book.

Notes on Usefulness:
It's neat to see services really come together, and auto generation of the proxy is still cool.

Differences/problems/mistakes -> troubleshooting:
-Minor issue deriving context of the book regarding which functions are to be adjusted where.

Lab #6: Designing a Service Contract

Members:
Rafael Zuniga, Stephen Cave

Summary:
Adding a name and namespace to the service contract results in an exception as expected.

Unfortunately, adding the next lines of code, actions and reply actions for operation1 and 2 causes an unintended exception, and I'm not sure what to do beyond check for syntax errors. The only thing notable is the book mentions to "Drill down from localhost.cs to Reference.cs" to put the new code, but no Reference.cs exists, and I'm not sure what "Drill down" means.

Notes on Usefulness:
Frustratingly enough, I apparently cannot design a service contract.

Differences/problems/mistakes -> troubleshooting:
-book mentions to "Drill down from localhost.cs to Reference.cs" to put the new code, but no Reference.cs exists, and I'm not sure what "Drill down" means. Inserted code nets an exception.

Tuesday, September 22, 2009

Lab #5: Hosting Multiple Services and Sharing Types

Members:
Rafael Zuniga, Stephen Cave

Summary:
Loading a pre-existing solution with multiple projects, we extend ServiceA and ServiceB by their corresponding implementations in MultiContractService, as well as with IAdmin. Also add return strings for each, simply detailing which function was called.


Next we add some references for the Host, add a good portion of book code to the app.config file to manage the multiple endpoints, and finally add code to main in program.cs to run our program.

Next we move to the InternalClient project, adding functionality to all the buttons so they can call our services.


Lastly we use the external client to get the wsdl and generate a proxy and finally we implement the external service calls through the buttons.

Notes on Usefulness:
Exploring usage of multiple endpoints and working both sides of development seems pretty important for real usage.

Differences/problems/mistakes -> troubleshooting:
-not much besides a few minor book code transfer errors. Not sure why copy is bugged like that.

Lab #4: Creating an IIS Host and Browsing Metadata

Members:
Rafael Zuniga, Stephen Cave

Summary:
In an effort to expose an endpoint via website, we first make some modifications to the supplied solution, adding a new website "IISHostedService", clearing the service implementation, modifying the @ServiceHost directive to associate with our service type, and making small changes to the web.config file regarding endpoint and service tags.
The next portion had us try to browse the metadata on the website. Unfortunately, due to some unknown issue, we could not get the website to display after about an hours worth of troubleshooting(notes are listed in the problems section). This may be an issue with windows 7 or my version of visual studio, which has worked alright up till now.
If I can figure out what the issue is, I will return and finish the last portion of the lab.
...
After enabling every IIS function under the sun, then going back to the FAQ on our class website and running ServiceModelReg -i on the 64bit v3.0 WCF framework, I think we finally have what we were looking for... Or maybe not.
Finally nailing down the issue, the book has another inconsistency in that at the behavior name flip flops in 2 example points between "ServiceBehavior" on page 54 and "returnFaults" on page 56, neither is really mentioned as a change in bold or anything to be aware of, but having swapped it, a mismatch is created. Lovely. Finally getting the correct output, though weirdly enough I must still have the svc file focused in VS for it to load the correct web address.
While as in the book there is now a link to the wsdl, clicking on it unfortunately brings us to another empty page. I shudder to think what may be behind this problem, or how to find it, as there is nothing left to enable, nor clues in the class FAQ.
Attempting to run svcutil for the last portion of this lab yields what appears to be results in cmd, but nothing is generated in visual studio, and I am unable to complete the lab.

Notes on Usefulness:
The intended effect of the lab seems very beneficial, but more and more it becomes frustrating working through errors in the book, and contradictions between my system and the books system, as well as the limited vision the book provides of what is supposed to be in the solution. Unfortunately no errors were generated in this lab, so the best we could muster was to poke around making changes here and there, hoping to stumble upon the issue.

Differences/problems/mistakes -> troubleshooting:
-when attempting to add a website to the solution, we get "Unable to create the website 'http://localhost/IISHostedService'. To access local IIS Web sites, you must install the following IIS components: IIS 6 Metabase and IIS 6 Configuration Compatibility Windows Authentication. In addition you must run Visual Studio in the context of an administrator account." Trying again brings another error, demanding Windows Authentication for IIS. After another enabling spree, the web site was added
-The book wants you to run the new website in debug mode (f5) but debugging is not enabled in Web.config and a prompt is supplied as a result. We enable debugging.
-When launched in either debugging or non-debugging, only a blank browser window is displayed, not the supposed metadata publishing. Weirder still, found debugging normally opens page http://localhost/IISHostedService/ but if we hit debug while looking at Service.svc, it fails to debug, and if we run without debugging, it loads the intended http://localhost/IISHostedService/Service.svc but there is no page to be displayed.
-apparently not all components of IIS were installed, and once installed they needed to be configured with the frustratingly obscure method described on the school website.
-Finally, a book inconsistency was found, that when fixed seems to let the website function properly as long as one debugs while the svc file is currently being focused. Still weird.
-once the website functioned, it still failed to properly generate wsdl for some unknown reason. The link is there, but it returns a blank page.

Tuesday, September 15, 2009

Lab #3: Using Tools to Generate Clients and Services

Members:
Rafael Zuniga, Stephen Cave

Summary:
Loading a premade solution, we are given a client and host project. Adding a WCF template we start our hello indigo service, adding code and references for both, and compiling with no errors.
Next we create a configuration file (after deleting the pre-supplied one) using WCF Service Configuration Editor, and enable service metadata with a metadata exchange endpoint.
Next we get to generate a client proxy with the Add Service Reference, which uses SvcUtil. A bunch of files are generated properly setting up the client, and after compiling the client is run and returns the intended output from the service.
Next we create another project with the WCF Service Library template - HelloIndigo. Small modifications to the service contract and implementation, and a compile results in no errors. Then we delete the app.config file and compile again - no errors. Next we hide the previous service files in Host, and reference to the new class library. With some more modifications to the program.cs and app.config files, we have the service referenced and can compile and run with no errors.
Next we move on to generating a proxy directly with SvcUtil, starting by allowing the host to continue running. We use visual studio's command line to access svcutil with the appropriate arguments and generate the proxy!
With another exclusion and some modifies to the client program.cs, we compile and run the client after no errors, and see the appropriate output.

Notes on Usefulness:
Learning how to construct proxies automatically is a very useful tool, where remembering all the specifications takes the place of constructing the code. Using SvcUtil directly also makes you look like a cool hacker in cmd mode, though typing anything in console is a pain and a half.

Differences/problems/mistakes -> troubleshooting:
-Supplied code in book for program.cs in Main() has some syntax errors with all the curly braces
-System.ServiceModel.AddressAccessDeniedException is thrown, got to remember to start visual studio with administrator privilages from now on (using windows 7 or vista I believe causes this)
-once again copy/paste from the book to load the command line string proved annoying to correct
-There's a grammar error in the book for the portion on renaming the service library .cs files
-localhostreference.svcmap is named reference.svcmap under local host in my version
-when modifying the final program.cs, the book states a "using()" when there shouldn't be one

Tuesday, September 8, 2009

Lab #2: Creating clients and services programatically

Members:
Rafael Zuniga, Stephen Cave

Summary:
First we create a service contract as service.cs with a single operation and implement it, adding contract attributes to the interface portions, adding a service type to implement the "HelloIndigo" function, and compiling to check completeness.
Next we create a host application named Host, that references our stuff in the HelloIndigo project and System.ServiceModel. Book code was used to write the main function as a ServiceHost instance and endpoint for the service.
Lastly we create a new console app to test the service, adding a Client project with a System.ServiceModel reference. The service contract is copied into a proxy for the client, and code is copied into the program.cs, that uses ChannelFactory for invoking the service. An endpoint is also initialized.
The program is run, host then client after compiling successfully. The output looks correct.

Notes on Usefulness:
This lab is quite useful for understanding the basic code that goes into creating and consuming a service programatically.

Problems/Mistakes/Differences -> troubleshooting encountered:
-When creating the Host, debugging the program led to a System.ServiceModel.AddressAccessDeniedException being thrown. This was fixed eventually by running visual studio as administrator.
-copy pasting code from the book source to the program isn't 1 to 1, random spaces seem to be inserted, so some review and adjustment was required to correct the errors.