Thursday, March 11, 2010

Syntax for directly calling the Web Service using HTTP GET

The syntax for directly calling the Web Service using HTTP GET is

http://server/webServiceName.asmx/functionName?parameter=parameterValue

Therefore, the call for our Web Service will be

http://localhost/work/aspx/SampleService.asmx/GetSecurityInfo?Code=IBM

Creating a .NET Web Service

REF: http://www.15seconds.com/Issue/010430.htm



Microsoft .NET marketing has created a huge hype about its Web Services. This is the first of two articles on Web Services. Here we will create a .NET Web Service using C#. We will look closely at the Discovery protocol, UDDI, and the future of the Web Services. In the next article, we will concentrate on consuming existing Web Services on multiple platforms (i.e., Web, WAP-enabled mobile phones, and windows applications).


Why do we need Web Services?


After buying something over the Internet, you may have wondered about the delivery status. Calling the delivery company consumes your time, and it's also not a value-added activity for the delivery company. To eliminate this scenario the delivery company needs to expose the delivery information without compromising its security. Enterprise security architecture can be very sophisticated. What if we can just use port 80 (the Web server port) and expose the information through the Web server? Still, we have to build a whole new Web application to extract data from the core business applications. This will cost the delivery company money. All the company wants is to expose the delivery status and concentrate on its core business. This is where Web Services come in.


What is a Web Service?


Web Services are a very general model for building applications and can be implemented for any operation system that supports communication over the Internet. Web Services use the best of component-based development and the Web. Component-base object models like Distributed Component Object Model (DCOM), Remote Method Invocation (RMI), and Internet Inter-Orb Protocol (IIOP) have been around for some time. Unfortunately all these models depend on an object-model-specific protocol. Web Services extend these models a bit further to communicate with the Simple Object Access Protocol (SOAP) and Extensible Markup Language (XML) to eradicate the object-model-specific protocol barrier (see Figure 1).

Web Services basically uses Hypertext Transfer Protocol (HTTP) and SOAP to make business data available on the Web. It exposes the business objects (COM objects, Java Beans, etc.) to SOAP calls over HTTP and executes remote function calls. The Web Service consumers are able to invoke method calls on remote objects by using SOAP and HTTP over the Web.


Figure 1. SOAP calls are remote function calls that invoke method executions on Web Service components at Location B. The output is rendered as XML and passed back to the user at Location A.

How is the user at Location A aware of the semantics of the Web Service at Location B? This question is answered by conforming to a common standard. Service Description Language (SDL), SOAP Contract Language (SCL) and Network Accessible Specification Language (NASSL) are some XML-like languages built for this purpose. However, IBM and Microsoft recently agreed on the Web Service Description Language (WSDL) as the Web Service standard.

The structure of the Web Service components is exposed using this Web Service Description Language. WSDL 1.1 is a XML document describing the attributes and interfaces of the Web Service. The new specification is available at msdn.microsoft.com/xml/general/wsdl.asp.


The task ahead


The best way to learn about Web Services is to create one. We all are familiar with stock quote services. The NASDAQ, Dow Jones, and Australian Stock Exchange are famous examples. All of them provide an interface to enter a company code and receive the latest stock price. We will try to replicate the same functionality.

The input parameters for our securities Web service will be a company code. The Web service will extract the price feed by executing middle-tier business logic functions. The business logic functions are kept to a bare minimum to concentrate on the Web service features.


Tools to create a Web Service


The core software component to implement this application will be MS .NET Framework SDK, which is currently in beta. You can download a version from Microsoft. I used Windows 2000 Advance Server on a Pentium III with 300 MB of RAM.

The preferred Integration Development Environment (IDE) to create Web Services is Visual Studio .NET. However, you can easily use any text editor (WordPad, Notepad, Visual Studio 6.0) to create a Web Service file.

I assume you are familiar with the following concepts:

Basic knowledge of .NET platform
Basic knowledge of C#
Basic knowledge of object-oriented concepts
Creating a Web Service


We are going to use C# to create a Web Service called "SecurityWebService." A Web Service file will have an .ASMX file extension. (as opposed to an .ASPX file extension of a ASP.NET file). The first line of the file will look like

<%@ WebService Language="C#" class="SecurityWebService" %>

This line will instruct the compiler to run on Web Service mode and the name of the C# class. We also need to access the Web Service namespace. It is also a good practice to add a reference to the System namespace.
using System;
using System.Web.Services;

The SecurityWebService class should inherit the functionality of the Web Services class. Therefore, we put the following line of code:
public class SecurityWebService : WebService

Now we can use our object-oriented programming skills to build a class. C# classes are very similar to C++ or Java classes. It will be a walk in the park to create a C# class for anyone with either language-coding skills.
Dot-net Web Services are intelligent enough to cast basic data types. Therefore, if we return "int," "float," or "string" data types, it can convert them to standard XML output. Unfortunately, in most cases we need get a collection of data regarding a single entity. Let's take an example.

Our SecurityWebService stock quotes service requires the user to enter a company code, and it will deliver the full company name and the current stock price. Therefore, we have three pieces of information for a single company:


Company code (data type - string)
Company name (data type - string)
Price (data type - Double)
We need to extract all this data when we are referring to a single stock quote. There are several ways of doing this. The best way could be to bundle them in an enumerated data type. We can use "structs" in C# to do this, which is very similar to C++ structs.
public struct SecurityInfo
{
public string Code;
public string CompanyName;
public double Price;
}

Now we have all the building blocks to create our Web Service. Therefore, our code will look like.

<%@ WebService Language="C#" class="SecurityWebService" %>

using System;
using System.Web.Services;

public struct SecurityInfo
{
public string Code;
public string CompanyName;
public double Price;
}

public class SecurityWebService : WebService
{
private SecurityInfo Security;

public SecurityWebService()
{
Security.Code = "";
Security.CompanyName = "";
Security.Price = 0;
}

private void AssignValues(string Code)
{
// This is where you use your business components.
// Method calls on Business components are used to populate the data.
// For demonstration purposes, I will add a string to the Code and
// use a random number generator to create the price feed.

Security.Code = Code;
Security.CompanyName = Code + " Pty Ltd";
Random RandomNumber = new System.Random();
Security.Price = double.Parse(new System.Random(RandomNumber.Next(1,10)).NextDouble().ToString("##.##"));
}


[WebMethod(Description="This method call will get the company name and the price for a given security code.",EnableSession=false)]
public SecurityInfo GetSecurityInfo(string Code)
{
AssignValues(Code);
SecurityInfo SecurityDetails = new SecurityInfo();
SecurityDetails.Code = Security.Code;
SecurityDetails.CompanyName = Security.CompanyName;
SecurityDetails.Price = Security.Price;
return SecurityDetails;
}

}


Remember, this Web Service can be accessed through HTTP for any use. We may be referring to sensitive business data in the code and wouldn't want it to fall into the wrong hands. The solution is to protect the business logic function and only have access to the presentation functions. This is achieved by using the keyword "[Web Method]" in C#. Let's look at the function headers of our code.
[WebMethod(Description="This......",EnableSession=false)]
public SecurityInfo GetSecurityInfo(string Code)

This function is exposed to the public. The "description" tag can be used to describe the Web Service functionality. Since we will not be storing any session data, we will disable the session state.
private void AssignValues(string Code)

This is a business logic function that should not be publicly available. We do not want our sensitive business information publicly available on the Web. (Note:- Even if you change the "private" keyword to "public," it will still not be publicly available. You guessed it, the keyword "[Web Method]" is not used.)
We can use the business logic in this function to get the newest stock price quote. For the purpose of this article I have added some text to the company code to create the company name. The price value is generated using a random number generator.

We may save this file as "SampleService.asmx" under an Internet Information Service (IIS)-controlled directory. I have saved it under a virtual directory called "/work/aspx." I'll bring it up on a Web browser.



This is a Web page rendered by the .NET Framework. We did not create this page. (The page is generated automatically by the system. I did not write any code to render it on the browser. This graphic is a by-product of the previous code.) This ready-to-use functionality is quite adequate for a simple Web Service. The presentation of this page can be changed very easily by using ASP.NET pagelets and config.web files. A very good example can be found at http://www.ibuyspy.com/store/InstantOrder.asmx.

Notice a link to "SDL Contract." (Even if we are using WSDL, .NET Beta still refers to SDL. Hopefully this will be rectified in the next version). This is the description of the Web Service to create a proxy object. (I will explain this in the next article.) This basically gives an overview of the Web Service and it's public interface. If you look closely, you will only see the "Web-only" methods being illustrated. All the private functions and attributes are not described in the SDL contract. The SDL contract for the SecurityWebService can be found in Appendix A.


view demo of SecurityWebService

How do we use a Web Service?


Now we can use this Web Service. Let's enter some values to get a bogus price feed.



By clicking the Invoke button a new window will appear with the following XML document



This is how the Web Service releases information. We need to write clients to extract the information from the XML document. Theses clients could be

A Web page
A console / Windows application
A Wireless Markup Language (WML) / WMLScript to interact with mobile phones
A Palm / Win CE application to use on Personal Digital Assistants (PDAs).
I will explain this process in the next article.
You can also call the Web Service directly using the HTTP GET method. In this case we will not be going through the above Web page and clicking the Invoke button. The syntax for directly calling the Web Service using HTTP GET is

http://server/webServiceName.asmx/functionName?parameter=parameterValue

Therefore, the call for our Web Service will be

http://localhost/work/aspx/SampleService.asmx/GetSecurityInfo?Code=IBM

This will produce the same result as clicking the Invoke button.

Now we know how to create a Web Service and use it. But the work is half done. How will our clients find our Web Service? Is there any way to search for our Web Service on the Internet? Is there a Web crawler or a Yahoo search engine for Web Services? In order to answer these questions we need to create a "discovery" file for our Web Service.


Creating a Discovery file


Web Service discovery is the process of locating and interrogating Web Service descriptions, which is a preliminary step for accessing a Web Service. It is through the discovery process that Web Service clients learn that a Web Service exists, what its capabilities are, and how to properly interact with it. Discovery file is a XML document with a .DISCO extension. It is not compulsory to create a discovery file for each Web Service. Here is a sample discovery file for our securities Web Service.






We can name this file "SampleService.disco" and save it to the same directory as the Web Service. If we are creating any other Web Services under the "/work/aspx" directory, it is wise to enable "dynamic discovery." Dynamic discovery will scan for all the *.DISCO files in all the subdirectories of "/work/aspx" automatically.




An example of an active discovery file can be found at http://services3.xmethods.net/dotnet/default.disco. By analyzing the discovery file we can find where the Web Services reside in the system. Unfortunately both these methods require you to know the exact URL of the discovery file. If we cannot find the discovery file, we will not be able to locate the Web Services. Universal Description, Discovery, and Integration (UDDI) describes mechanisms to advertise existing Web Services. This technology is still at the infant stage. UDDI is an open, Internet-based specification designed to be the building block that will enable businesses to quickly, easily, and dynamically find and transact business with one another using their preferred applications. A reference site for UDDI is http://uddi.microsoft.com.
There have been a lot of Web Services written by developers. www.xmethods.com is one of the sites that has an index of Web Services. Some developers are building WSDL search engines to find Web Services on the Web.


Deploying a Web Service


Deploying the Web Services from development to staging or production is very simple. Similar to ASP.NET applications, just copy the .ASMX file and the .DISCO files to the appropriate directories, and you are in business.

The future of the Web Services

The future looks bright for the Web Service technology. Microsoft is not alone in the race for Web Service technology. Sun and IBM are very interested. There are SOAP toolkits available for Apache and Java Web servers. I believe Web Services needs a bit of work, especially the Web Service discovery process. It is still very primitive.

On a positive note, Web Services have the potential to introduce new concepts to the Web. One I refer to as "pay per view" architecture. Similar to pay-TV, we can build Web sites that can generate revenue for each request a user sends (as opposed to a flat, monthly subscription). In order to get some data, we can sometimes pay a small fee. Commercially this could be handy for a lot of people.


Examples


Online newspaper sites can publish a 10-year-old article with a $2 "pay per view" structure.
Stock market portals can itemize every user portfolio for every single stock quote and build pricing and discount structures.
And the list goes on ...
On a very optimistic note, Web Services can be described as the "plug and play" building blocks of enterprise Business to Business (B2B) Web solutions.

Appendix A




xmlns="urn:schemas-xmlsoap-org:sdl.2000-01-25">








This method call will get the company name and the price for a given security code.














This method call will get the company name and the price for a given security code.












This method call will get the company name and the price for a given security code.



elementFormDefault="qualified" xmlns="http://www.w3.org/1999/XMLSchema">























Some handy web services

REF: http://www.actionscript.org/forums/showthread.php3?t=70742

Scientific Web Services

http://www.webservicex.net/ConvertAc...tion.asmx?WSDL - Convert acceleration
http://www.webservicex.net/CovertPressure.asmx?WSDL - Convert Pressure
http://www.webservicex.net/ConvertDensity.asmx?WSDL - Convert Density
http://www.webservicex.net/ConverPower.asmx?WSDL - Convert Power
http://www.webservicex.net/ConvertAngle.asmx?WSDL - Convert Angles
http://www.webservicex.net/ConvertTorque.asmx?WSDL - Convert Torque
http://www.webservicex.net/convertMe...ight.asmx?WSDL - Convert Weight
http://www.webservicex.net/convertVolume.asmx?WSDL - Convert Volume
http://www.webservicex.net/ConvertTemperature.asmx?WSDL - Convert Temperature
http://www.webservicex.net/convertFrequency.asmx?WSDL - Convert Frequency
http://www.webservicex.net/Astronomical.asmx?WSDL - Convert Astronomical Values (i.e. - the speed of light)
http://www.webservicex.net/ConvertForec.asmx?WSDL - Convert Force
http://www.webservicex.net/ConvertEnergy.asmx?WSDL - Convert Energy
http://www.webservicex.net/ConvertArea.asmx?WSDL - Convert Area
http://www.webservicex.net/ConvertCooking.asmx?WSDL - Convert Cooking units
http://www.webservicex.net/ConvertComputer.asmx?WSDL - Convert Computer units (i.e. - megabytes)
http://www.webservicex.net/ConvertWeight.asmx?WSDL - Convert Weights
http://www.webservicex.net/ConvertSpeed.asmx?WSDL - Convert Speeds
http://www.webservicex.net/length.asmx?WSDL - Convert Distances
http://www.webservicex.net/periodictable.asmx?WSDL - Periodic Table (i.e. - find atomic weight of Oxygen)

Validation Web Services

http://www.webservicex.net/CreditCard.asmx?WSDL - validate a credit card number
http://www.webservicex.net/ValidateEmail.asmx?WSDL - validate email address
http://www.tpisoft.com/smartpayments/validate.asmx?WSDL - validate credit card number
http://ws.cdyne.com/emailverify/Emai...mail.asmx?wsdl - validate email
http://ws.cdyne.com/phoneverify/phoneverify.asmx?wsdl - validate phone number

Business Web Services

http://www.webservicex.net/stockquote.asmx?WSDL - get stock quote of a particular company

Geographic Web Services

http://www.webservicex.net/uklocation.asmx?WSDL - get location of place in the UK
http://www.webservicex.net/AustralianPostCode.asmx?WSDL - get location in Austrailia of a certain Post code
http://www.webservicex.net/uszip.asmx?WSDL - find location in US based on the ZIP code
http://www.webservicex.net/country.asmx?WSDL - Get country details (i.e. - the currency)
http://www.webservicex.net/geoipservice.asmx?WSDL - get IP address of the persons computer
http://www.webservicex.net/whois.asmx?WSDL - a WHOIS domain lookup
http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl - find geo location on earth based on Zip code
http://www.innergears.com/WebService...yZip.asmx?WSDL - Get City and state based on ZIP
http://www.innergears.com/WebService...Zips.asmx?WSDL - Calculate distance between 2 zip codes
http://www.innergears.com/WebService...tate.asmx?WSDL - get a list of ZIP codes in a City
http://www.innergears.com/WebService...ords.asmx?WSDL - calculate distance between Lat/Long

Communication Web Services

http://demo.wsabi.org/axis/services/...ngService?wsdl - check and see if a Yahoo! user is online/offline
http://ws.acrosscommunications.com/Fax.asmx?WSDL - send a FAX to someone
http://www.abysal.com/soap/AbysalEmail.wsdl - send an email (this does add a small ad at the bottom of the outgoing email, but it's just text. It looks like the ad at the bottom of Hotmail emails)
http://ws.strikeiron.com/ReversePhoneLookup?WSDL - reverse Phone number lookup/validator

Weather Web Services

http://www.ejse.com/WeatherService/Service.asmx?WSDL - get the weather based on Zip code/City Name
http://www.innergears.com/WebService...yZip.asmx?WSDL - get the weather based on ZIP
http://www.innergears.com/WebService...yZip.asmx?WSDL - get a 9 day forecast
http://www.innergears.com/WebService...ICAO.asmx?WSDL - get the weather forecast based on ICAO code
http://www.innergears.com/WebService...ings.asmx?WSDL - Get state weather warnings
http://www.innergears.com/WebService...ICAO.asmx?WSDL - get weather around an airport
http://weather.terrapin.com/soap/HurricaneService.wsdl - get information on current storms/hurricanes

Miscellaneous Web Services

http://www.27seconds.com/Holidays/US...ates.asmx?WSDL - Get the date of a certain Holiday
http://www.27seconds.com/Holidays/US...vice.asmx?WSDL - the other half of the Holdiay Web Service above, now includes Great Britain Holidays. (Documentation)
http://webservices.codingtheweb.com/bin/qotd.wsdl - Quote of the day
http://www.boyzoid.com/comp/randomQuote.cfc?wsdl - a random Quote
http://www.swanandmokashi.com/HomePa...cope.asmx?WSDL - get the Horoscope reading
http://www.hlrs.de/quiz/quiz.wsdl - a quiz webservice, returns a question, 4 options, and the correct answer

Friday, March 5, 2010

Custom Save Button for Web Enabled Form

REF: http://blogs.microlinkllc.com/dmcwee/archive/2009/04/30/custom-save-button-for-web-enabled-form.aspx David McWee's Blog

I recently found the need to submit and save Infopath 2007 browser enabled form data. The submit is very straight forward when using browser enabled forms, but the ability to save the form is not so straight forward or so you might think. After thinking for a little while on how to work around the save capability I found a very simple process to allow users to Submit and Save InfoPath Browser enabled forms back to the SharePoint Library without any custom code.


Designing the Form


Begin by creating an InfoPath 2007 form with a button and some text box control(s).

Add an additional Data Source called submitFormName

Add a Data Connection


Create the Data Source Connection that will allow the form to be submitted to the SharePoint site using the following steps.

Click on the Manage Data Connections… and then click the Add button


Select Create a new connection to: and Submit Data then click Next >


On the next screen Select a destination for submitting your data choose the To a document library on a SharePoint site then choose Next >


Now provide a URL to the document library you want to submit your data to. In the next to the file name textbox click on the fx button. Click on the Insert Field or Group… button and select the submitFormName field.


Click the OK button on the Select a Field or Group window and on the Insert Formula Window. On the data connection wizard check the Allow overwrite if file exists option. Click Next >


You can now provide a custom name for your data connection then click Next >.

Click Close on the Data Connections window

Add the actions to the Custom Button

Double Click on the button control added to the InfoPath form

Select Rules and Custom Code for the Action and provide a label and control ID, if desired, of your choice.

Click on the Rules… button and then click on the Add button in the Rules Window.


Name this rule Set File Name and click on the Set Condition… button. For the Condition check if the submitFormName is blank. Click the OK button.



Click the Add Action… button. For the action select Set a field's value, for the Field select submitFormName, for the Value use, using the fx builder use the expression concat("Account Request - ", now()) then click OK.


Click OK on the Rule Window. Now click on the Add… button again on the Rules window. Name this rule Submit Form and do not specify a condition. Add an action to Submit using a data connection and select the Data connection created in the last section.


Click the OK button on the Action and Rule windows.


Click the Add… button on the Rule Window. Name this rule Close Form and do not specify a condition. Add an action to close the form.


Click OK on all of the windows until you are back to the InfoPath form designer.



Now publish your form to the SharePoint site library that was specified in the Data Connection section. Once the form is published go to that library and choose Settings->Form Library Settings


Under the General Settings choose Advanced settings



In Advanced Settings under the Browser-enabled Documents choose Display as a Web page and then click OK


This will force the InfoPath form to be opened using Form Services.


Now complete a form and submit it. Then click on the form, change a value and submit again. You should see your changes applied after you submit.

Prepare your Master Pages

REF: http://vspug.com/dwise/2007/01/08/one-master-to-rule-them-all-two-actually/

« HowTo: Filter a View based on Workflow StatusMystery Master Page or CMS Gotcha »One .Master to Rule Them All (Two, actually)
One of the biggest annoyances with Sharepoint 2007 is the quirky things you have to do in order to customize a site. This is especially true when it comes to custom master pages. You create a stunning master page in Designer, configure the site to use it, then load the page and wait to bask in the glory. Lo and Behold! It worked! Job done, go grab a beer … but you better drink it fast because Sharepoint has a nasty surprise in store for you. That master page only works on the content pages in your site. System pages (i.e. viewlists.aspx) will refuse to use your amazing Master page. All that work is wasted on a half complete user experience. Or is it?

Why is it not doing what I tell it to do?
This is because those system pages are hard-wired to use a different master page (application.master) . To make matters worse, you only get one application.master for everywhere. You could go modify this file, but be careful: changes to this will affect ALL pages based on that master, everywhere. It's not something that can be customized on a site-by-site basis. To make matters still worse, Microsoft *will* update this file in upcoming patches, so odds are good that it will break on you sometime in the future, and likely with little warning.

Ok, so what's the skinny?
Create a custom httpModule and install it on your Sharepoint site that remaps which .Master pages your pages use. If you aren't familiar with httpModules, fear not, they are extremely simple.

The httpModule sits in the middle of the http request processing stream and can intercept page events when they initialize. The pages load up and say "I'm going to use application.master", to which your module replies "not on my watch, buddy" and not so gently forces the page to use the Master page of your choice.

The Gory Details
(this assumes that you already have the aforementioned Nifty Master Page created. If not, please search Google for any of the hundreds of tutorials on how to do this)

Prepare your Master Pages
You will need two .Master pages. One to replace default.master and the other to replace application.master. It is very important that when you are creating these pages that you include all of the ContentPlaceHolders that exist in the .Master page you are replacing. Throw any ContentPlaceHolders that you are not using in a hidden DIV at the bottom of the page – but before the closing FORM tag (the only exception to this seems to be "PlaceHolderUtilityContent" which goes in after the closing form tag). Once in place, you can use the normal Master Page options in the UI to select the default.master replacement.

Second, be sure to remove the Search Control from your Application.Master replacement. The reason for this is that the search box does not normally appear on system pages and will cause an error during rendering.

You can probably simplify this a bit by using nested master pages, but I haven't had a chance to look into that yet.

Step 1 – Create the httpModule
Create a new Class Library project in Visual Studio and start with the code below. So simple, even a manager could do it (maybe). Obviously, you will have to change the path to match your environment. Oh, and sign the assembly as well.


using System;
using System.Web;
using System.Web.UI;
using System.IO;

public class MasterPageModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
}
void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
Page page = HttpContext.Current.CurrentHandler as Page;
if (page != null)
{
page.PreInit += new EventHandler(page_PreInit);
}
}
void page_PreInit(object sender, EventArgs e)
{
Page page = sender as Page;
if (page != null)
{
// Is there a master page defined?
if (page.MasterPageFile != null)
{
// only change the application.master files as those are the offenders
if (page.MasterPageFile.Contains("application.master"))
{
page.MasterPageFile = "/_catalogs/masterpage/MyCustom.master";
}
}
}
}

public void Dispose()
{
}
}

Note the path above: that is required so that all pages can find the Master page as not all pages are running from the site context

This is a simplified example but you can see the potential here. With this in place, YOU control the horizontal and YOU control the vertical. Or, for a more modern reference, YOU decide who gets the red pill and who gets the blue pill.

Build it and then throw the DLL in the /bin folder in your Sharepoint site root (usually something like InetpubwwwrootwssVirtualDirectories80 in). You may have to create the in folder if one is not there. Once you have it working the way you want, you will need to sign it and move it to the GAC, but this works for getting started.

Step 2 – Register the httpModule
Another easy step – throw in the bolded line below in your web.config file at the bottom of the httpModules section. This section should already be there.


… stuff you dont care about …



Step 3 – Load the Page
Navigate to the home page of your site. That should work normal as it is using the normal Sharepoint Master page logic. Now go to a System page, like 'Documents' , 'Lists' or 'Pictures'. These should now be using your Master page

If you've followed the this tip you will actually be able to see the real error, if any, when you load the page.

Step 4 – Go get that beer
Do you really need instructions for this?

Special thanks to K. Scott Allen for his post showing how to change the .Master page using an httpModule. You will notice that the code above bears an amazing resemblance to his.



3/1/2007 – UPDATE!
In response to comments, I have updated these instructions, in particular, I have added the "Prepare your Master Pages" section that addresses most of the issues encountered in the comments.

Also, do not use this method if your sharepoint install has the shared Service Provider (SSP) installed on the same web application as your main sharepoint environment. The system pages used by the SSP do not work properly when their master page is replaced like this. I'm sure there is a logical reason why, I simply haven't had the time to dive into it.

Using centrally managed SharePoint data connection files with InfoPath 2007

REF: aidangarnish.net November 3, 2008 11:06 by Aidan

When deploying InfoPath forms with data connections between environments it is possible to use centrally managed data connection files to make the process a bit smoother.

To set up a centrally managed data connection do the following:

From your InfoPath form select Data Connections... from the Data menu
Select the data connection you want to make centrally managed and click the Convert button
A .udcx file will be created in a site collection data connections library you select so it may be necessary to set up a data connections library first
Navigate to the site collection data connections library and save the .udcx file locally
Go to SharePoint Central Administration - Application Management - Manage Data Connection Files
Upload the .udcx file to the central data connection files library
Go back to the InfoPath form and remove the existing data connections.
Recreate the data connections using Search for connections on a Microsoft Office SharePoint Server
Create the connection using the .udcx file that was saved to the site collection data connection library but make sure that you click on Connection Options... and select Centrally Managed
Configure the controls on the form to use the data connection as normal
The form will now use the centrally managed data connection. To deploy to another environment (eg. UAT, Production) you will need to upload the .udcx file to the relevant SharePoint Central Administraion after altering it to use the connection properties relevant to the new environment. To update the .udcx file open it in a text editor and alter the following parameters (example is for a connection to a SharePoint list):

{175EC1CF-BF41-4848-B775-40277642B99F}
https://productionurl.co.uk/

Where ListId is the SharePoint list id and WebUrl is the url of the site collection that holds the SharePoint list.

When you deploy your InfoPath form it will reference the centrally managed .udcx file allowing it to seamlessly connect with data in the new environment.

Creating a custom save function for InfoPath 2007 browser based forms

REF: aidangarnish.net December 8, 2008 14:41 by Aidan

I recently had an issue where it was necessary to only save some of the fields on an InfoPath form back to the form library. To do this required a combination of custom code and submission to a form library using a data connection.

The steps to do this were as follows:

1. Add a Save button to the form

2. Right click the save button and select button properties, change Action dropdown to Submit and click Submit Options...

3. In the submit options select Send form data to a single destination and choose SharePoint document library from the dropdown

4. Click Add to add a new data connection and follow the wizard to set this up to submit your form to the required library

5. Now that the data connection has been set up, select Perform custom action using Code and click the Edit Code button - this will create a submit method in the code behind file

6. In the submit method place the code to do the custom "stuff" and then submit the form to the data connection. The code will look something like:

public void FormEvents_Submit(object sender, SubmitEventArgs e)
{

//remove values from the form that you don't want to be saved
XPathNavigator xPnName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Name", NamespaceManager);
xPnName.SetValue("");

//submit the form using the data connection

DataConnections["Main submit"].Execute();

//set e.CancalableArgs to be false once form has successfully saved

e.CancelableArgs.Cancel = false;
}

To give the form a unique filename and allow updates to saved forms do the following:

1. Create a new xml node called dtNow, give it a default value of now() and uncheck the Update this value when the result of the formula is recalculated box.

2. Go to Data and Data Connections and Modify the submit data connection created above.

3. In the Filename field add concat(userName(), dtNow) and check the Allow overwrite if the file exists checkbox.

Finally, convert the data connection used to submit the form to be centrally managed as described
Here



http://sladescross.wordpress.com/2009/10/07/infopath-custom-save/

http://blogs.3sharp.com/davidg/archive/2007/12/21/4504.aspx