# Readme.html Sample

This topic inludes the source code for the Readme.html Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/interop/dotNET/

## Sample Source Code

    <html>
    <head>
    <title>
    WebLogic Workshop&trade; Web Service .NET Client Example
    </title>
    <style type="text/css">
    h1,
    h2,
    h3,
    h4,
    p,
    li,
    blockquote
    {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	margin-left: 0px;
    }
    p, li { font-size: 12; }
    blockquote { font-size: 12; }
    blockquote { margin-left: 1em; }
    ul { list-style-type: square; }
    </style>
    </head>
    <body>
    <h1>WebLogic Workshop&trade; Web Service .NET Client Example</h1>
    <h2>Introduction</h2>
    <p>
    This sample demonstrates how to create a .NET client for a WebLogic Workshop web service (a JWS).
    The client uses the sample web service Conversation.jws, found in samples/async. Conversation.jws
    is a conversational web service that can optionally communicate results to its client via a callback.
    The sample .NET client is fully capable of participating in conversations with Conversation.jws, as well
    as receiving results via callback.</p>

    <h2>Contents</h2>

    <blockquote>
      ConversationClient.asmx.cs
    <blockquote>
        The C# source file of the ConversationClient .NET web service that acts as a client to Conversation.jws.  The instructions
    below describe how to create a .NET project into which this file will be copied.</p>
    </blockquote>
    </blockquote>

    <h2>Instructions</h2>

    <h3>In WebLogic Workshop</h3>
    <p>Test Conversation.jws by running it from the WebLogic Workshop visual development
    environment or by browsing to <a href="http://localhost:7001/WebServices/async/Conversation.jws" target="_blank">http://localhost:7001/WebServices/async/Conversation.jws</a> in a browser. Click on the Test Form tab to test the web service.</p>
    <blockquote>
    <p>If you specify "true" for useCallbacks, hit refresh until the <tt>onResultReady</tt>
    callback appears.</p>
    <p>If you specify "false" for useCallbacks, invoke getRequestStatus until the request
    is fulfilled, then invoke terminateRequest.</p>
    </blockquote>

    <h3>In Visual Studio .NET</h3>
    <ol>
    <li>Create a new project following these steps:<br><br>
    <ol>
    <li>Select File->New->Project.</li>
    <li>Select "Visual C# Projects".</li>
    <li>On the right side, select "ASP.NET Web Service".</li>
    <li>Change the location from <tt>http://localhost/WebService1</tt> to <tt>http://localhost/test</tt>.</li>
    <li>Select OK.</li>
    </ol>
    <br>
    </li>
    <li>Select the Service1.asmx web service in the Solutions Explorer (pane on the right by default) and rename it to ConversationClient.asmx.</li>
    <li>In the main edit window (which is mostly blank) select the "click here to switch to code view" link.</li>
    <li>Replace the contents of the file (ConversationClient.asmx.cs) with the contents of the same file from this sample.</li>
    <li>Construct a proxy for the Conversation.jws web service by following these steps:<br><br>
    <ol>
    <li>Get the WSDL file by browsing to the URL of the Conversation with "?WSDL" appended to the URL (e.g. <a href="http://hostname:7001/WebServices/async/Conversation.jws?WSDL" target="_blank">http://hostname:7001/WebServices/async/Conversation.jws?WSDL</a>).</li>
    <li>Using the browser's "File->Save As...", save the WSDL to a temporary location (e.g. c:\temp) as "Conversation.wsdl".</li>
    <li>In a CMD window, cd to the temporary location to which you saved Converation.wsdl.</li>
    <li>Use .NET's wsdl.exe command to create a proxy from the WSDL.  Type "wsdl Conversation.wsdl".  This should result in a Conversation.cs file being written to the current directory.  This is the C# proxy class for the Conversation.jws web service.</li>
    <li>Copy the Conversation.cs file to the .NET web service project you created above.  If you are using the default configuration, this will be <tt>c:\Inetpub\wwwroot\test</tt>.</li>
    <li>Back in Visual Studio .NET, import the proxy class by selecting "Project->Add Existing Item..." and selecting Conversation.cs.</li>
    </ol>
    <br>
    </li>
    <li>Build the project by pressing Ctrl-Shift-B.  If it builds without errors, you are ready to run.</li>
    </ol>

    <h3>To Run the Client</h3>
    <ol>
    <li>In Visual Studio .NET, press F5 to run the "solution".  A browser will appear with links for each method.</li>
    <li>Select "start".  When its form appears, enter "true" or "false" (without the quotes) for <tt>useCallbacks</tt> and for <tt>useIPAddress</tt> (the latter just determines whether the callback URL is constructed using the hostname or IP address, in case the hostname is not fully qualified).</li>
    <li>Invoke the "start" method by clicking the button.  If you are watching the log for Conversation.jws in a different browser, a "refresh" will show the arriving request and the resulting actions.  The browser created by Visual Studio to receive output will remain blank since the "start" method returns void.  You can close it.</li>
    <li>If you chose to use callbacks, a message will be written to the file c:\temp\ConversationClient.log when the callback arrives.</li>
    <li>If you chose not to use callbacks, you must continually invoke "getStatus" until the status is returned.  Then you should invoke "finish" to finish the conversation ("dangling" conversations take up resources on the WebLogic Workshop server).</li>
    <li>Again, if you have a different browser monitoring the Test View for Conversation.jws, a "refresh" there will show you all activity that has taken place.</li>
    </ol>
    </html>