AWG Blogs

Saturday, October 16, 2010

WSS Inaccessible after Windows Updates

After a scheduled Windows Update, several WSS sites became inaccessible. The Application Event Log contained events like:Unknown SQL Exception 33002 occured. Additional error information from SQL Server is included below.

Access to module dbo.proc_GetRunnableWorkItems is blocked because the signature is not valid.

I got similar errors when attempting to open any of the tables of the affected content databases in the embedded SQL Server (SSMS to \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query).
Relatedly, WSS creates copious logs at
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS whenever anything goes wrong with one of the WSS services, which fills up the hard drive. This may have had something to do with the failed update.

Anyway, after much googling and trying various solutions, some of which did more harm than good, I followed one suggestion and tried running the following command:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>PSCO
NFIG -cmd upgrade -inplace b2b -wait -force

After some time, the operation completed and all my sites were oparational!

Saturday, September 25, 2010

Missing GPOs After DC Decommission

I followed the standard Microsoft method for decommissioning a domain controller. After retiring the server from lab, to my consternation, I started getting errors such as the following, for instance, when running gpupdate /force from a member workstation:The processing of Group Policy failed. Windows attempted to read the file \\my.domain\sysvol\my.domain\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\gpt.i
ni from a domain controller and was not successful. Group Policy settings may no
t be applied until this event is resolved. This issue may be transient and could
be caused by one or more of the following:
a) Name Resolution/Network Connectivity to the current domain controller.
b) File Replication Service Latency (a file created on another domain controller
has not replicated to the current domain controller).
c) The Distributed File System (DFS) client has been disabled.

I found out that all the GPOs were missing from \\my.domain\sysvol\my.domain\policies. In fact even the policies folder was missing until and I created a couple of new GPOs in gpmc.msc.
The only way to fix things now is delete the dangling referenced GPOs from Group Policy Management (for which there is no corresponding ID file in the policies folder), and recreate them. I should have either backed up the DC or the GPOs individually so that I could restore them.
I followed the decommision procedure to a tee, however, I did encounter errors which I assumed were cleared up after fixing them...but apparently not.

Other symptoms of this problem: when you right click the policy in Group Policy Management and click edit, this error message appears: "Failed to open the group policy object. You may not have appropriate rights." "Details: the system cannot find the path specified."

Besides the missing GPOs, the NetLogon share was missing as well. This was solved by creating a folder called "Scripts" in \\my.domain\sysvol\my.domain and rebooting the computer.

Sunday, September 19, 2010

gSOAP Client Setup Steps

My environment is Vista x64, Visual Studio 2008

Download gSoap from here: http://www.cs.fsu.edu/~engelen/soap.html. I downloaded gsoap_2.8.0.
open command prompt and change to gsoap_2.8.0\gsoap-2.8\gsoap\bin\win32
enter: wsdl2h -c -o iptocountry.h http://www.ecubicle.net/iptocountry.asmx?wsdl

enter: soapcpp2 -c -C iptocountry.h

Create a new Visual Studio 2008 Visual C++ Win32 Console Application with Empty project selected (no Precompiled header)

Copy the following files generated above by gsoap to your VS project directory (with the .vcproj).

files to copy: iptocountrySoap12.nsmap, soapC.c, soapClient.c, soapH.h, soapStub.h

Copy stdsoap2.c and stdsoap2.h to your VS project directory from gsoap_2.8.0\gsoap-2.8\gsoap\

Include the files in your project

Add a file called myclient.c to your project with the following contents:
#include "soapH.h" // obtain the generated stub
#include "iptocountrySoap12.nsmap"
main()
{
struct soap *soap = soap_new();
struct _ns1__FindCountryAsString *_myipv4address;
struct _ns1__FindCountryAsStringResponse *myresponse;
char text[20];

_myipv4address = (struct _ns1__FindCountryAsString *)malloc(sizeof(struct _ns1__FindCountryAsString));
myresponse = (struct _ns1__FindCountryAsStringResponse *)malloc(sizeof(struct _ns1__FindCountryAsStringResponse));

fputs("enter an IP: ", stdout);
fflush(stdout);
if ( fgets(text, sizeof text, stdin) != NULL )
{
char *newline = strchr(text, '\n'); /* search for newline character */
if ( newline != NULL )
{
*newline = '\0'; /* overwrite trailing newline */
}
printf("text = \"%s\"\n", text);
}

_myipv4address->V4IPAddress = text;


if (soap_call___ns2__FindCountryAsString(soap, NULL, NULL, _myipv4address, myresponse) == SOAP_OK)
printf("Country code is = %s\n", myresponse->FindCountryAsStringResult);
else // an error occurred
soap_print_fault(soap, stderr); // display the SOAP fault on the stderr stream
}


Compile.

If you have installed a Microsoft Windows 7 SDK and are getting "fatal error LNK1104: cannot open file 'kernel32.lib'" try adding the path to the SDK lib (e.g. C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib) to your project Configuration Properties \ Linker \ General \ Additional Library Directories.

Tuesday, August 24, 2010

Sharepoint 2010 ASP.NET Impersonation

I was getting

"Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

when attempting to access my list linked to an external content type, a remote SQL Server Database.

To resolve the issue, I opened IIS 7 \ Sites \ SharePoint - 80 \ Authentication \ ASP.NET Impersonation \ edit, then added a domain account here that could access the SQL Server.

I'm sure this might not be the best practice, security-wise, but hey, at least now it works!

Oh, to even get as far as the above login failed error, I had to do:

Central Administration \ Manage service applications \ Business Data Connectivity Service \ [my external content type] \ Set Object Permissions, then add the above domain account.

---
Update:

Trying on another machine in a different domain now and got: "access denied by business data connectivity"
when trying to add a connection to the External Content Types.
Solved by going to Central Administration \ Manage service applications \ Business Data Connectivity Service \ Set Metadata Store Permissions, and adding my domain account with all available permissions.

ORM LINQ Style

I'm rediscovering LINQ, and came across this article - http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx - by Scott Guthrie (probably not the first time I've read this article).

Ever wonder why arrows seem to point in the opposite direction in E-R diagrams? This paragraph explains it. It ties in well with O/RM, in that the mapped objects will be composed of their children. I always tended to look at it in the direction of the diamond head as more intuitive speaking of foreign keys and all.

The arrows between the four entity classes above represent associations/relationships between the different entities. These are typically modeled using primary-key/foreign-key relationships in the database. The direction of the arrows on the design-surface indicate whether the association is a one-to-one or one-to-many relationship. Strongly-typed properties will be added to the entity classes based on this. For example, the Category class above has a one-to-many relationship with the Product class. This means it will have a "Categories" property which is a collection of Product objects within that category. The Product class then has a "Category" property that points to a Category class instance that represents the Category to which the Product belongs.

Sunday, August 8, 2010

I Discover DCI

I just now discovered DCI; see http://www.artima.com/articles/dci_vision.html

All I can say is, it's about freakin' time! For too long we programmers have struggled with staying true to OO, but faltering because as a model OO does not provide an adequate place to store algorithms. That's why of late, I have been putting the algorithms in stored procedures. Hey maybe that's a DCI best practice! Too early to tell. Hopefully a language comes out that supports DCI.

BTW, is Trygve Reenskaug a god or what?

Saturday, July 31, 2010

Controller Example

Found a good example of the notion of controller of the MVC:

they handle web requests and URLs of the request map to a controller class and a closure within the class
http://grails.org/Quick+Start

Essentialy it's the thing you need (generated automatically in this case, i.e. grails) to map a URL, crafted according to the conventions of the current framework in use, to a desired output. So http://localhost:8080/my-project/book/list maps to an output containing a list of book items.

Sunday, July 25, 2010

Using WDS for VMware Server Deployment

The goal was to follow this excellent walk-through -- http://www.oakdome.com/lab/?page_id=78 -- to capture and deploy a Windows XP image (as a test) from and to a guest in the free VMware Server.

Everything went real well except for a few stumbling blocks.

First, I found out through much googling that it's acceptable, even preferred to run the WDS on a separate server than the DHCP server. Perfect. My DHCP server is a CISCO router anyway. For some reason I thought they had to be on the same server and a Windows one at that.

Then, I had to setup the guest to use the right nic. Again, I found out that I need to run Manage Virtual Networks as Administrator (on Vista) or else the Automatic Bridging options are greyed out.

Then I learned through a few threads on social technet that the reason the Windows Deployment Services Image Capture Wizard would freeze after checking the Upload image to WDS server checkbox and entering the server name is because the network connection is not setup. I hit shift-F10 and did ipconfig, and there was no network. The solution is to export the currently loaded boot image from the WDS to a temp directory. Then make sure you have WAIK (for Vista) installed on the WDS or another server to which you copy the wim file image. Then copy all the files from C:\Program Files\VMware\VMware Tools\Drivers\vmxnet to c:\temp\vmxnet. Then C:\Program Files\Windows AIK\Tools\PETools>imagex /mountrw c:\capture\capturebootimage.WIM 1 c:\image
Then
C:\Program Files\Windows AIK\Tools\PETools>peimg /inf=c:\temp\vmxnet\*.inf /image=c:\image\Windows
Then C:\Program Files\Windows AIK\Tools\PETools>imagex /unmount /commit c:\image
Then copy back the image, and reimport it into the boot images of WDS, naming it something like "Boot image with VMXnet drivers." Then when you PXE boot choose that image from the menu.

This same process has to be done for the deployment image. But this time, since you are using the Vista boot image, the command has to be run from a Vista or later OS apparently, or else you get PEIMG failed to complete the operation with status code 0x800703fb. when attempting to inject the drivers. I managed to inject the drivers by installing WAIK on a Windows 7 Ultimate VM, with VMware tools installed, from which I injected the vmxnet drivers. Be sure to do c:\windows\system32>imagex /mountrw c:\temp\boot.wim 2 c:\image -- Note the "2." Evidentally, there's a second image in the boot.wim that came with the Vista sources, which contains the WDS image. Note that the boot.wim file was copied from the Vista 32 DVD sources NOT the Windows 7 sources. The latter will not work.

Tuesday, July 6, 2010

Set clientJsLocation when using HTML_AJAX in XAMPP

Please remember to set clientJsLocation, e.g.:
$server->setClientJsLocation('C:/xampp/php/PEAR/data/HTML_AJAX/js/');


Or else, you will get an error like: Unable to find javascript file: .\pear\data\HTML_AJAX\js\HTML_AJAX.js

HTML_AJAX 0.5.6 with XAMPP 1.7.3.

The only thing I can think of that causes this is reinstalling HTML_AJAX-beta via pear install? Otherwise, I guess it's understand we should always set the path. Now you know. (speaking to self)

Friday, July 2, 2010

WSS 3.0 Incoming Email -- Must use FQDN

I wanted to be able to send email from my Outlook to a WSS discussion list. After much testing and troubleshooting with various configurations (and a lot of googling) I came to realize that (barring any workarounds that I'm not aware of) the CA - Operations - Incoming E-Mail Settings - E-mail server display address MUST match the machine FQDN! It cannot be the machine's DNS name. I tried adding the DNS name of the machine here, and email would just get bounced back (or get stuck in the Queue since I didn't have the smart host configured and this is not an Exchange server).

So as a result, I can send email using discussions@mymachine.fq.dn -- but NOT discussions@mymachine.dns.name.

I'm sure there are workarounds, but they might involve fiddling with Exchange servers and/or DNS servers that are outside of my control.

Now that I think about it, it makes sense that the WSS doesn't understand the DNS implications; why should it? On the other hand, why can't WSS figure out that mymachine.dns.name is the local server? Hmmmmm. Perhaps it's an IIS 6 SMTP limitation...

Saturday, June 5, 2010

MyEDB - NO Indexes to be Managed

This is because in My Entity Database all Entities are defined in a single index table called entity, which provides the link between the types and properties. The actual values of an entity reside in type tables which themselves are all indexed on their value column.

So, no indexes to add and manage. That eliminates probably 50% of a DBA's duties...

ref: http://myedb.blogspot.com/2010/06/myedb-no-indexes-to-be-managed.html

Friday, June 4, 2010

Errors when adding FormView to SmartPart with AJAX

When I added a FormView control embedded in an UpdatePanel in a User Control, in a SmartPart with AJAX I got the following error when attempting to switch to Edit mode:
Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl00_xxxx'. If it is being updated dynamically then it must be inside another UpdatePanel.
I never did find a solution to this problem. But I found that if I cleared out the web parts out of the Web Part zone, then readded the smart part that appears to have fixed the issue.

I did run into other issues when adding multiple AJAX-enabled SmartParts to a Web Part zone, such as the entire zone blanking out other than the one control when switching to Edit Mode. Again, clearing out the controls and re-adding them, seems to resolve these issues, although I fear they'll crop up again...

Sunday, May 23, 2010

The Original MVC

The MVC is the object of somewhat of a religious ferver in the web development community. Many frameworks -- e.g. Zend Framework, CodeIgniter, etc. -- appear to me to be attempts at literal instantiations of the paradigm. Those frameworks have little appeal to me because they lock the developer into this single way of doing things. When the inevitable time comes that that way is not appropriate, the developer must resort to the framework's many workarounds, e.g. helpers or plugins (to plug the leaks? :)), extended classes, or hacks.

I wondered if the MVC is being used as it was originally intended so I researched it and read some of the creator's comments.

The MVC wasn't even called the model-view-controller; originally it was the model-view-editor. Additionally it was conceived by Trygve M. H. Reenskaug to solve the problem of network problems of the yards of the Aker Group in Norway. I think the idea got over-subscribed to by wannabe developer purists and their disciples, and as a consequence was bastardized into the impractacal forms we see depicted today around the internet.

Now, I admit, I haven't done complete dilligence on this research and so my conclusions may be premature or inaccurate. But when I see what I perceive to be serious inconsistencies between a implementations/interpretations of a model, I have to question whether the model as we know it is itself in its purest form.

For example, the Zend Framework, in which I'm no expert, apparently presupposes a single view delivered to a user at one time. If the model data must be aspected on the page, the developer has to use helpers or the ActionStack or some other hack to get the data on the page. I think this is a too-strict, too-literal, and consequently untenable, implementation of the MVC.

By contrast, the author of MVC appears to indicate multiple views presented can be the norm:
A user task may commonly be better performed with several Views present on the screen at the same time. The user will want to manipulate these Views through pointing at them, through selection in menus, or through some other means. Commands like selection typically apply to several Views at the same time. The purpose of an Editor is to establish and position a given set of Views on the screen, to coordinate them and to provide the user with a suitable command interface.

Some comments by Reenskaug lead me to wonder whether the MVC or MVE is applicable to web development at all:
Conversely, a view should never know about user input, such as mouse operations and keystrokes. It should always be possible to write a method in a controller that sends messages to views which exactly reproduce any sequence of user commands. http://heim.ifi.uio.no/~trygver/2007/MVC_Originals.pdf
How can we conclude that a PHP script can be an implementation of a "view" then? Is this what Reenskaug meant when he referred to the "perverted variants" of his model found in texts? http://heim.ifi.uio.no/~trygver/

Sunday, May 16, 2010

CodeIgniter versus MyEDB

CodeIgniter like most CMS's and their underlying frameworks assumes entities are mapped to tables in relational databases. MyEDB presumes the MyEDB model of data (http://www.myedb.com).

CodeIgniter like most (PHP based) CMS's assumes the view (in the MVC pattern) is composed of templates in the form of PHP files (some CMS's use non-PHP files but are nonetheless PHP interpretable in some form) which are passed parameters ala Smarty. MyEDB uses XSLT.

CodeIgniter allows the user/developer to invoke a single entry point to the system through a single controller class action pair. MyEDB allows the client to invoke a series of class action pairs, in essence multi-action controllers (maybe like Spring multiactioncontrollers? but more specifically multiple controllers) to be executed iteratively in sequence through the HTTP posting of appropriately named array variables, specifically class method pairs.

In CodeIgniter (and Zend Framework, and CakePHP, and... you get the picture) the view is an intrinsic component of the controller (defeating the notion of controller view independence). In MyEDB, the "view" is abstracted from the "controller" by a series of processing steps (see image below), ensuring total flexibility. In short, in MyEDB you are not chained down to a single way of doing things from an MVC perspective!

MyEDB Source
myedb.com

Thursday, May 6, 2010

Uploading InfoPath Form Templates

So, I'm working through Sharepoint 2007 for Dummies, and I'm on page 200, and I go to upload my test form, and get The restricted trust level is not supported. Quickly googled, and found http://sharepointknowledgebase.blogspot.com/2009/03/restricted-trust-level-is-not-supported.html. So I follow the fellow's excellent advice (Tools - Form Options - Security and Trust - Domain) and the error goes away.


But it can be that easy. I just get a new error (what do I expect right?): The form template is not browser-compatible. So google around again, and finally decide to do the following: Tools - Form Options - Compatibility - (check) Design a form template that can be opened in a browser or InfoPath. Click Ok. Then an error shows up in my form. It's the combo box, apparently not supported on the web. So I delete it; error goes away.

Save the form and try uploading again, first clicking Verify. Now it says This form template has not been correctly published to be browser-enabled. Open the form template in InfoPath Design mode, and click Publish Form Template in the Design Tasks task pane. Follow the steps in the Publishing Wizard to republish the form template, and then try again. So I do as instructed, choosing to "Publish this form template as a template in a document library." Published it. Still get the same error. Then, I tried selecting "To a network location" and leaving the third screen in the Publishing Wizard blank per http://www.novolocus.com/category/sharepoint/infopath/, Next, Ok, Next, publish. This saved the form again. I then tried verifying the form once more in the Upload Form Template page and it verified...I then uploaded it, got another error: The timer job for the operation has been created. However, it cannot be run because the administrative service for this server is not enabled. To run the timer job, use the stsadm.exe command line utility (stsadm.exe -o execadmsvcjobs). Googled again and got http://vspug.com/ssa/2007/10/22/a-deployment-or-retraction-is-already-under-way-for-the-solution-publishing-infopath-form/. So I start the Windows SharePoint Services Administration service, run the stsadm.exe -o execadmsvcjobs command, check the Manage Form Templates page, but see that my form is "Installing". Found this: http://www.infopathdev.com/forums/p/8034/29193.aspx, tried the suggestions, including turning on my other sharepoint server in the farm that happened to be off, but that didn't fix it. I was able to delete the "Installing" form templates through the timer definitions page and subsequently through the Manage Form Templates. Still need to figure out why it won't finish "Installing". Later, I noticed that the second Sharepoint web frontend server is low on disk space. Checking how a 25GB drive can fill up so quickly, I used windirstat and found that C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS is taking up 21 GB of space. Huh? So I delete all those log files and try uploading again. Still getting "Installing" forever....
Finally I decided that the second Sharepoint server, which is sitting on a VMware Workstation guest, needs to be removed from the farm as it appears to be experiencing issues, e.g. the ever-increasing logs mentioned earlier (containing entries like "Tracing Service lost trace events," as well as a failing system clock. As soon as I removed the second server, and attempted the template upload, the results were successful.

Saturday, May 1, 2010

Replacing Form Action Scripts with sed

I needed to replace all form action scripts in all my XSLT templates, specifically to make the script relative to the current path. So I did:
find . -name "*.xsl" -type f -exec sed -i "s#\([\"|'|>]\)/index.php#\1index.php#g" {} \;
There are a few of things to notice about this command:

I used a double quote and not a single quote for the sed script namely because A single quote may not occur between single quotes, even when preceded by a backslash. *

The parenthesis required backslashes because sed apparently is not running in extended mode on my machine.

The argument to sed needs to be quoted to avoid being parsed by the bash shell interpreter. Aside the from the parenthesis the only other character needing escaping is the double quote in the regex. Even the \ don't need further escaping because a double quote string preserves the literal value of all characters except \, $, and `. The backslash has its special meaning only if followed by ", $, `, \, and newline. *http://answers.google.com/answers/threadview/id/496910.html

Friday, April 9, 2010

Use the User DSN When Debugging

Couldn't figure out why I kept getting "failed to call the odbc driver connection utility" when attempting to configure data tables in the DataSet designer in Visual Studio 2005 on a Windows 7 machine -- a duo that has incompatibility problems apparently.

I finally realized that the problem was that I had created a System DSN (like I always do) for the ODBC connection. I created a corresponding User DSN and it worked like a charm.

Friday, April 2, 2010

Virtual Host in Tomcat and NAT

Well, I didn't figure out how to separate the apps by port, but I did learn that it's possible to do so by IP -- by setting the name attribute in the Host tag of server.xml.

The problem appeared however when I attempted to port forward port 80 to the second host entry in the m0n0wall NAT configuration. Browsing to the site from outside the firewall kept bringing me back to the first host entry which by default was set to localhost. That will never do, because I don't want external users seeing the Tomcat management page or welcome page for that matter. That was the whole point of creating a separate app in a separate location on the hard drive (which was done by the way via setting the docBase attribute of the Context tag which goes under the Host tag. I was creating an Open Blue Dragon or openbd application and I didn't want it sitting under the default webapps virtual host.

I solved the problem by simply setting my new app, the second host in server.xml, to localhost, and assigning the default app a second IP (from a second NIC) for management purposes. I'm not sure why or how, but this fixed the problem. I can now access my ColdFusion web app from outside the firewall through port forwarding. And the managment app is only visible from the server itself.

Thursday, April 1, 2010

Don't forget the Share Permissions...

I was getting errors when attempting to access a Visual Source Safe DB configured as a share from the network:

error: Microsoft Visual SourceSafe
Unable to open user login file ....user.log

I thought how could this be, my computer user account is in the Administrator's group. I even tried copying a file to the ...data\loggedin folder, and got this error:

Destination Folder Access Denied
You need permission to perform this action

Silly me. The sharing permissions were not set up correctly.

To fix, open sharing on the VSS DB folder. Click Permissions. Add the Users group, and assign Full Control.

Tuesday, March 30, 2010

MIssing BIN DLLs from VS Website References

If you are ever in the predicament where after copying over a Visual Studio 2005 website to another machine and are not finished working out the dependencies, here's a tip: Make sure all the assemblies listed in the "add assembly" tags in the web.config can be found on the current machine first, or else none of the Bin folder DLLs will be added as references, no matter how hard you try.

I ran into this problem, and Visual Studio 2005 refused to add the Bin folder references, until those web.config assemblies had their match in the GAC. Go figure!

Tuesday, March 16, 2010

MyEDB SQL One Liner

In this case the use case is to reduce the quantity of each product variation ("ron" in myedb speak), i.e. items in a shopping cart, when the total transaction is finalized. The following code can be placed in a transaction inside a MySQL 5.x stored procedure:


update property natural join int_prop natural join entity_property natural join entity
inner join medb_transaction on entity.eid = medb_transaction.eiddst and entity_property.ron = medb_transaction.ron
and property.prop_group_id = medb_transaction.prop_group_id
set int_val = int_val - qty
where medb_transaction.eidsrc = 8 and property.prop_id = 15

The prop_id 15 is the ID of the 'quantity' property. eidsrc is passed as a parameter to the stored procedure and represents the user id (or "eid" for entity id in myedb speak ;) ).

Wednesday, March 10, 2010

New myedb.com Domain for Framework

My first post to describe my MyEDB (My Entity Database) framework/CMS was placed on a holding site at netfirms:

This is my stand-in site to promote my concept of an "Entity Database" which is more than a relational database -- it gives the DB designer more flexibility in setting up and tearing down entities. I call it and the supporting code framework MyEDB for My Entity DB.



It does away with the traditional notion of entity relationships, and just focuses on pure entities, no relationships and the headaches they cause Database designers. The purpose for relationships has evolved from an ingenuous desire to model entities and their relationships into being merely an optimization device. My framework gets rid of the pretense. All optimization is stored natively through the use of single type tables.

One added benefit of this static architecture is that of being essentially a low level database per se, but one that is accessible to database designers.

Combine this with an elegant PHP-based RESTful MVC framework, and all that's left is defining inputs and outputs and coding them. And the effort of coding the input/output wire-ups simply scales to the level of your requirements -- i.e. pay per requirement.
Requirements can be defined as any of the following:
- Create a form for Inserting, updating, or deleting an entity (e.g. a customer record)
- Create a new view of the entity, purely for display (e.g. a product, or any entity. Examine one of your Excel spreadsheets rows for examples of "entities")
- Build search functionality for all your entities or only a subset



Copyright 2010

Wednesday, February 24, 2010

Connecting to Web Service with .NET

I needed to connect to a remote Java WSRF Web Service having access only to the WSDL and login credentials. At first I tried using Visual Studio 2008, but found it doesn't support old style WSE so well, so had to revert to Visual Studio 2005, over which I installed Microsoft WSE 3.0.msi.

I then pointed wsdl.exe at the https://url?wsdl to generate the proxy class, which I put in the App_Code folder of a test web project. wsdl.exe caused the Service class to inherit from System.Web.Services.Protocols.SoapHttpClientProtocol. I had to replace this with Microsoft.Web.Services3.WebServicesClientProtocol to get the proper authentication interface.

I then had to manually add a wse3policyCache.conf file to get the policy setting intialized (see https://www-secure.symantec.com/connect/forums/newbie-help-adding-security-header-request-object#comment-3625021).

Then, following guidance in http://bytes.com/topic/net/answers/560786-how-add-soap-header-soap-message, I added a SoapHeader class as well as an attribute to the target proxy class method.

The SoapDocumentMethodAttribute Action attribute was set to a blank string so I had to set that to the fully qualified url of the method from the WSDL, i.e. .../PortType/TheMethod.

In the client code, I then just had to call myproxy.SetClientCredential(..), then I could use the proxy class without problems.