Set KeepAlive Header in PHP SoapClient

8. March 2010

Some of you may have read my first post about some problems with PHP comminucating with a WCF Web Service (or vice versa). Well I was working on another issue with it as well just recently. We needed a way to turn off KeepAlives, set Connection to Close, (Connection: Close) in the HTTP header while PHP was sending the call to the web service. After much research it turns out the standard PHP SoapClient object can't do this.

What I did find out though, is that PHP was capable of doing this, but in PHP you would need to use curl when making the request.  curl allows you to set the HTTP Headers of a POST.  Which in this case, is excatly what was needed!

So this code concept will allow you to set the HTTP Headers, turn off Keep Alive ("Connection: Close") when making a POST to a WCF Service.

Note: we are still using the SoapClient object and override the __doRequest method just as in the previous post. Also, the setup/configuration is still the same as in the previous post.

 

Anyway, I know I'm not a PHP developer, but wanted to share this with everyone since it has to do with another platform communicating with a WCF Web Service.

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

ASP.NET

Simple WYSIWYG Content Management

3. March 2010

I had to put this small site together for someone and one of the things he wanted was a way to put up his own content for one of his pages. In a sense, this is a content management system in its simplest form. So I came up with, what I think, is a simple and effective way using XML as the data source. Here are the requirements for what I am doing:

  • WYSIWYG Editor: TinyMCE
  • Data Source: XML File
  • XMLDataSource in ASP.NET
  • Read/Write Access to App_Data or whatever folder you choose to store the XML file.


The goal was to have the user login, edit his page and have the front end page read it and show it. I took it one step further and made the XML file handle multiple pages, this way in the future if he needs a few more pages, it's already setup.

First, here is the format of the XML file

As you can see, it's a very simple format.

Second, Lets look at how some of the markup will look like for the page where the editing will take place.  This is a very simple format

Note: You will still need to add the code for the tinymce editor so it converts the textbox into the editor

You'll notice the DropDownList is using the XMLDataSource as it's DataSourceID. This is so we can keep track of which page we will be editing.  You'll see how below in the code behind.

Here is the code behind for the Submit button

 

Not much huh?  The XMLDataSource takes care of saving the document for you, so you don't have to worry about it.  What's going on here is the following:

  • We read the XML document into our own XMLDocument object
  • Find the node we want based off the item in the drop down ("page" name)
  • Set the text of that node to the text of the editor.
  • Call the Save() method from the XMLDataSource object.

 

You'll notice we don't have to do any type of encoding for the editor text.  The Save() method will automatically convert items as needed from what I have found. For example a < will turn into "&lt;"

Here is some code on how to read it back out. This is explicity specifying the page name, but you could make it dynamic as needed.  I chose to read this out into a LiteralControl.

Sample Markup for ASPX

 

Sample Code Behind for ASPX Page

 

That's it everybody.  Simple, quick and easy.  You don't have to worry about setting up any SQL database, you just need to make sure to give read/write access to the XML file you will be using.  Don't forget this can handle multiple pages as well.

Note: I tested basic data entry and a copy and paste from word and all turned out ok in the XML file. I thought I would need the <![CDATA[]]> tag but I didn't...well not from what I have ran into yet.


 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

ASP.NET

TinyMCE Image Upload Plugin for ASP.NET

11. February 2010

 

Ok this was my first time at trying to mod a javascript WYSIWYG editor. My goal was to create a TinyMCE image upload plugin for ASP.NET.  I just recently started using TinyMCE as my editor of choice and noticed that it was not convenient in anyway to insert an image to the editor.  By default the "advimage" plugin only allows you to point to an existing image via a URL.  Well, in my opinion this is kind of worthless because users will want to insert a new image from their own computer while creating content.  What I did was modify the advimage plugin to include such functionality.  I did try searching the exisiting third party plugin site for TinyMCE but solutions either required PHP or the ones in .NET were not and "AJAX" like UI.  Because I'm a .NET guy I made a simple image uploader tool that is now part of the advimage plugin.

I would like to post the code of what I did, but I think this post would be a bit difficult to read. However, I did leave comments in the image.htm file.  I've set this up on codeplex so please go to the project site to download the the files needed. Both the source and just the files you need are available for download.

Project Location:  http://tinyslupload.codeplex.com

 

Overall concept of changes:

- Added a generic handler to handle the image upload into the directory specified
- Created a Silverlight 3 application that performs a file upload with a progress bar indicator
- Modified the image.htm file to include a new tab with the silverlight application in there
- Modified the javascript language file to include 2 new variables
- Added the Silverlight.js file

Screenshots

 

 

 

 

 

Project Location:  http://tinyslupload.codeplex.com

 

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

ASP.NET, Silverlight