using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Data;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Test.Framework.Interfaces.BusinessLayer.BusinessEntities
{
/// <summary>
/// This is a shared interface for web services that must conform to a standard API and be called without a web reference.
/// </summary>
/// <remarks>
/// Note that the targetIdList parameters are XML, not delimited lists, so data type can be specified if necessary.
/// Note that this interface is designed for Fire-And-Forget operations, except where a return is absolutely required.
/// Note that each method has a unique name to simplify attribute creation in the implementing code.
/// Note that details concerning how and why one might call a web service in this way are found at the following link...
/// http://www.codeproject.com/KB/cpp/CallWebServicesDynamic.aspx
/// </remarks>
public interface IGenericWebServiceStub
{
#region InterfaceMethods
/// <summary>
/// This saves the given objects.
/// </summary>
/// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param>
void Create(string targetObjectList);
/// <summary>
/// This deletes each object that has an ID in the given list.
/// </summary>
/// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param>
void Delete(string targetIdList);
/// <summary>
/// This initializes a new object and returns it, without having saved the object.
/// </summary>
/// <returns>This is a list containing exactly-one object, such as a DataSet serialized as XML.</returns>
string Initialize();
/// <summary>
/// This retrieves each object that has an ID in the given list.
/// </summary>
/// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param>
/// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns>
string Retrieve(string targetIdList);
/// <summary>
/// This retrieves all objects.
/// </summary>
/// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns>
string RetrieveAll();
/// <summary>
/// This retrieves the count of existing objects.
/// </summary>
/// <returns>This is the count of objects in the data store.</returns>
long RetrieveCount();
/// <summary>
/// This executes a run-operation.
/// </summary>
void Run();
/// <summary>
/// This updates the given objects.
/// </summary>
/// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param>
void Update(string targetObjectList);
#endregion //InterfaceMethods
}
}
mkamoski
Contributor
5694 Points
1565 Posts
interface for web services that must conform to a standard API and be called without a web refere...
Dec 14, 2009 06:54 PM|LINK
http://mkamoski1.wordpress.com/2009/12/14/interface-for-web-service-without-a-web-reference/
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Data; using System.Data.Objects; using System.Data.Objects.DataClasses; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; namespace Test.Framework.Interfaces.BusinessLayer.BusinessEntities { /// <summary> /// This is a shared interface for web services that must conform to a standard API and be called without a web reference. /// </summary> /// <remarks> /// Note that the targetIdList parameters are XML, not delimited lists, so data type can be specified if necessary. /// Note that this interface is designed for Fire-And-Forget operations, except where a return is absolutely required. /// Note that each method has a unique name to simplify attribute creation in the implementing code. /// Note that details concerning how and why one might call a web service in this way are found at the following link... /// http://www.codeproject.com/KB/cpp/CallWebServicesDynamic.aspx /// </remarks> public interface IGenericWebServiceStub { #region InterfaceMethods /// <summary> /// This saves the given objects. /// </summary> /// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param> void Create(string targetObjectList); /// <summary> /// This deletes each object that has an ID in the given list. /// </summary> /// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param> void Delete(string targetIdList); /// <summary> /// This initializes a new object and returns it, without having saved the object. /// </summary> /// <returns>This is a list containing exactly-one object, such as a DataSet serialized as XML.</returns> string Initialize(); /// <summary> /// This retrieves each object that has an ID in the given list. /// </summary> /// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param> /// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns> string Retrieve(string targetIdList); /// <summary> /// This retrieves all objects. /// </summary> /// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns> string RetrieveAll(); /// <summary> /// This retrieves the count of existing objects. /// </summary> /// <returns>This is the count of objects in the data store.</returns> long RetrieveCount(); /// <summary> /// This executes a run-operation. /// </summary> void Run(); /// <summary> /// This updates the given objects. /// </summary> /// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param> void Update(string targetObjectList); #endregion //InterfaceMethods } }one-way web services one way web service
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: interface for web services that must conform to a standard API and be called without a web re...
Dec 15, 2009 03:56 AM|LINK
Hi,
if u are talking About Posting data.. then chk for below Code snnipted
string sXml = "<?xml version=\"1.0\" ?>" ;
sXml += "<soap:Envelope "
sXml += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " ;
sXml += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " ;
sXml += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" ;
sXml += "<soap:Body>" ;
sXml += "<Add xmlns=\"http://tempuri.org/\">" ;
sXml = sXml + "<a>" + a.value + "</a>" ;
sXml = sXml + "<b>" + b.value + "</b>" ;
sXml += "</Add></soap:Body></soap:Envelope>"
then Post the String using webRequest and webresponse...
HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://localhost/ASP.NET/MyWebService.asmx");
HttpWebResponse response =(HttpWebResponse)request.GetResponse();
request.Header = ("SOAPAction", "http://tempuri.org/Add");
request.Header = ("Content-Type", "text/xml; charset=utf-8" ) ;
Console.WriteLine("Request header count: {0}",request.Headers.Count);
WebHeaderCollection header = request.Headers;
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
mkamoski
Contributor
5694 Points
1565 Posts
Re: interface for web services that must conform to a standard API and be called without a web re...
Dec 16, 2009 01:47 PM|LINK
All --
My seminal post above presents the general idea.
However, given that ideas change, the latest and greatest will probably be here...
http://mkamoski1.wordpress.com/2009/12/14/interface-for-web-service-without-a-web-reference/
...which I have just updated.
HTH.
Thank you.
-- Mark Kamoski
mkamoski
Contributor
5694 Points
1565 Posts
Re: interface for web services that must conform to a standard API and be called without a web re...
Dec 16, 2009 01:58 PM|LINK
Qwe --
That is not a bad start.
But, what then?
How does one implement a full-blown solution?
My seminal post in this thread addresses that "next level" of questions about such a service.
What is the API of that service?
What is the expected service contract?
Etc.
My answer to THOSE questions is to use a generic web service interface.
For the latest and greatest of my idea, see the following...
http://mkamoski1.wordpress.com/2009/12/14/interface-for-web-service-without-a-web-reference/
HTH.
Thank you.
-- Mark Kamoski