SDK - Workaround for Uploading Files in the TRIM Web Service using WSE 3.0

  • KM510471
  • 20-Sep-2008
  • 20-Sep-2008

Archived Content: This information is no longer maintained and is provided "as is" for your convenience.

Reference

Workaround for Uploading Files in the TRIM Web Service using WSE 3.0

Return to TRIM Web Service Articles page

When updating your WSE (Web Services Enhancements) from version 2.0 SP 3 to version 3, the WSE loses some of the functionality that enabled uploads to work properly. The functionality lost is Microsoft.Web.Services2.Attachments and Microsoft.Web.Services2.Dime. The following workaround allows someone working with WSE 3.0 to maintain the functionality without significantly changing their code.

WSE 3.0 Workaround

Assumptions: Developer is on Windows 2003, with Visual Studio 2005, .Net Framework 2.0, and WSE 3.0.

  • First, install WSE 2.0 SP3 (for Visual Studio developer 2003)
  • Reference both WSE 2 SP3 and WSE 3.0 in the code.
  • Create a dummy project in VS 2003 with reference to the TCT and WSE 2 SP3 and reference the code for the EngineWse Class, and copy and paste the code into the VS 2005 project.
  • For the EngineWse Class code in VS 2005, change the Execute code from syobject[]to object []. When creating the engine to do the attachments, use the code from the examples in the TCT pdf, which looks like the following (In C#, with slight changes):
EngineWse engine = new EngineWse();
 
engine.Credentials = new System.Net.NetworkCredential(<username>,<password>,<domain>);
engine.Timeout = 1000000;
 
Upload upload = new Upload();
 
Microsoft.Web.Services2.SoapContext reqc = engine.RequestSoapContext;
Attachment att = new Attachment("Incoming","application/octet-stream",<filename>);
reqc.Attachments.Add(att);
upload.AttachmentId= "Incoming";
upload.TransferType = TransferTypeType.attachment;
 
TrimRequest request = new TrimRequest();
request.Items = new Operation[] { upload };
TrimResponse response = engine.Execute(request);
  • Ensure you have added references at the top of your code relevant to EngineWse and WSE, including:
using System.Diagnostics;
using System.Xml.Serialization;
using System.Web.Services.Protocols;
using System.Web.Services;
using Microsoft.Web.Services2;
using Microsoft.Web.Services2.Attachments;
using Microsoft.Web.Services2.Dime;
using Microsoft.Web.Services3;
  • Run the code, and it should work! If Visual Studio 2003 is not available, reference the code below for EngineWse.

References

EngineWse Class Code:

/// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name = "EngineSoap", Namespace = "http://www.towersoft.com/schema/webservice/trim2/")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Result))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(RecordClause))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(LocationClause))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Operation))]
    public class EngineWse : Microsoft.Web.Services2.WebServicesClientProtocol
    {
 
        /// <remarks/>
        public EngineWse()
        {
            this.Url = "http://sharepoint01/trimct2/trim.asmx";
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/ListProperties", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public PropertyDescription[] ListProperties(string ObjectName)
        {
            object[] results = this.Invoke("ListProperties", new object[] {
                        ObjectName});
            return ((PropertyDescription[])(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginListProperties(string ObjectName, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("ListProperties", new object[] {
                        ObjectName}, callback, asyncState);
        }
 
        /// <remarks/>
        public PropertyDescription[] EndListProperties(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((PropertyDescription[])(results[0]));
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/ListProperty", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public PropertyDescription ListProperty(string PropertyName)
        {
            object[] results = this.Invoke("ListProperty", new object[] {
                        PropertyName});
            return ((PropertyDescription)(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginListProperty(string PropertyName, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("ListProperty", new object[] {
                        PropertyName}, callback, asyncState);
        }
 
        /// <remarks/>
        public PropertyDescription EndListProperty(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((PropertyDescription)(results[0]));
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/Execute", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public TrimResponse Execute(TrimRequest req)
        {
            object[] results = this.Invoke("Execute", new object[] {
                        req});
            return ((TrimResponse)(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginExecute(TrimRequest req, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("Execute", new object[] {
                        req}, callback, asyncState);
        }
 
        /// <remarks/>
        public TrimResponse EndExecute(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((TrimResponse)(results[0]));
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/ExecuteXml", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string ExecuteXml(string xml)
        {
            object[] results = this.Invoke("ExecuteXml", new object[] {
                        xml});
            return ((string)(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginExecuteXml(string xml, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("ExecuteXml", new object[] {
                        xml}, callback, asyncState);
        }
 
        /// <remarks/>
        public string EndExecuteXml(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/ListPropertiesXml", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string ListPropertiesXml(string ObjectName)
        {
            object[] results = this.Invoke("ListPropertiesXml", new object[] {
                        ObjectName});
            return ((string)(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginListPropertiesXml(string ObjectName, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("ListPropertiesXml", new object[] {
                        ObjectName}, callback, asyncState);
        }
 
        /// <remarks/>
        public string EndListPropertiesXml(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
 
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.towersoft.com/schema/webservice/trim2/ConvertToXml", RequestNamespace = "http://www.towersoft.com/schema/webservice/trim2/", ResponseNamespace = "http://www.towersoft.com/schema/webservice/trim2/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string ConvertToXml(TrimRequest req)
        {
            object[] results = this.Invoke("ConvertToXml", new object[] {
                        req});
            return ((string)(results[0]));
        }
 
        /// <remarks/>
        public System.IAsyncResult BeginConvertToXml(TrimRequest req, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("ConvertToXml", new object[] {
                        req}, callback, asyncState);
        }
 
        /// <remarks/>
        public string EndConvertToXml(System.IAsyncResult asyncResult)
        {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
    }
 
    /// <remarks/>