Author Archives: admin

Python SUDS Library Client

I was trying to create a ‘quick and dirty’ python SOAP client and was finding it difficult. The WSDL I was dealing with wasn’t a simple one, which, of course, made creating a client a bit more difficult. Add to the fact that I’m far from a python expert (have been tired of learning the ‘latest/greatest’ new toy), so finally started learning python reluctantly.

I found this post in StackOverflow that listed a number of python SOAP libraries and I started working through the examples. I finally settled on using SUDS. It’s not the most up-to-date library – the last development done on in was in 2010. But frankly, it’s the only one from which I could obtain results.

That being said, it wasn’t as straightforward as I would have liked. My first language is PERL; my second is Java. So maybe ‘thinking in python’ was not as easy for me. But still, I have found it a good language to work with, which is why I have been forcing myself to use it instead of PERL lately.

So, my code…..

There are groups of parameters in the WSDL I’m using, which required me to create dictionaries of dictionaries:

sort = dict(sortPolicyId='RELEVANCE',order='DESCENDING')
criteria = dict(searchPhrase='test', sortPolicy=sort)
params = dict(maximumResults=1000, searchTimeOut=24000)
contextParams = dict(ContextualCriteria=criteria,SearchCriteriaParameters=params)

The next part, passing them, does come directly from the documentation:

results = client.service.contextualSearch(**contextParams)

Then the next hard part: I couldn’t figure out how to get the values out. What I finally found was an example for pysimplesoap that I could use: Pull the results from the results. That is:

resultList = results.results

At this point, I had something from which I could pull values:

for item in resultList:
    print item.catalogEntry.id

… which gave me the values I needed.

Creating a Database Upon Deploy of Microsoft Web Site

Our development work includes a website we are creating for a client for whose system we don’t have direct access. We need a way to create a Web Deploy Package that we can turn over to them and ask them to deploy on their system.

Creating the Web Deploy Package was easy – just follow the directions that can be found in a number of places to use the GUI within Visual Studio 2012 and create it. The hard part was getting the database to create itself.

Theoretically, according to what I was reading, I should have to do is click the box that says, Execute Code First Migrations (runs on application start). Nope. Didn’t work. The database wasn’t created when I deployed. And, when I ran the application, nothing happened; no database was created.

I did try creating the database before running the app, then expecting the tables to be created. but they weren’t.

After much struggling, and a whole lot of research, I finally got it working. The following are the steps that I needed to have in place for this to occur:

  1. Within your Configuration.cs (if using C#) file (created automatically when you create a migration), set:
    • AutomaticMigrationsEnabled = true
  2. Create a duplicate of your connection string in your web.config file.
    • In the deployment settings, on the first string (your original string), check the box that says Execute Code First Migrations (runs on application start)
    • On the second string, check the box that says, Update database
  3. Create a database user for your database. Windows Authentication didn’t work. Neither did ‘sa’, although that was supposed.
  4. Upload some data. Click the Configure database updates link on the Settings. You’ll be given the option to add SQL files to run after the database is created. Attach one with some minimal data for your database.

And that worked! I created the database on the other server. I created the user, with SA access on the new database. I ran my deployment script, as per the instructions provided and voila! the new tables were created and populated!

 

Mounting a Windows Drive on Ubuntu

We have a development system that is separate from our regular corporate system. Unfortunately, that means that any off-site backups aren’t happening. In order to allow for a backup of data we need to keep, I needed to mount a Windows drive to a Linux box, to copy the files over to the corporate system for backup.

I tried for half a day to accomplish this, using both NFS and CIFS mounts. The first thing I discovered was that the drive I was trying to mount to was not a physical drive on the box I was trying to access. Apparently, that’s not acceptable for NFS. And, to my chagrin, CIFS would allow it, but I could never write to the drive. Next issue I found was that the mount didn’t like network logins; I needed to use a login from that machine, and I needed to make sure the drive had write permission for that user. Perhaps that’s why I couldn’t write to the non-local drive.

So, with a local login, and a local drive to the Windows box, I was able to accomplish my task.

On the Windows box, I did a simple share. And I made sure the drive had write permissions for the local user I would use. On the Ubuntu box, I used the following in the fstab file:

//server/share /ubuntu/mountpoint cifs user=windowslocaluser,password=userpw,defaults 0 0