Export (0) Print
Expand All

 

Connected Services Framework 3.0
Connected Services Framework 3.0 Developers Guide Send comments on this topic.
Using a Proxy Class to Communicate with the WES
See Also

You can use a proxy class to communicate with the WES that you have created. Before you create the proxy class you must deploy your WES. For more information, see Deploying a Well-enabled Service.

Create a Proxy Class

To create a proxy class complete the following steps:

  1. Open the Visual Studio 2005 command prompt and run the following command (replace YourWesUrl with the URL of your WES, WESProxy.cs with the name for your output class, and SampleServiceNamespace with the namespace for your service:

    Wsewsdl3 YourWesUrl?wsdl /l:CS /out:WESProxy.cs /n:SampleServiceNamespace /protocol:SOAP12 /type:soapClient

  2. Open the proxy class file you have just created and add the following namespace declarations to the class. Do not add any declarations that will cause duplicates with namespaces already declared in the class.

    using System.ComponentModel;
    using System;
    using System.Xml.Serialization;
    using System.Web.Services.Protocols;
    using Microsoft.Web.Services3.Messaging;
    using Microsoft.Web.Services3.Addressing;
    using System.Diagnostics;
    using Microsoft.Web.Services3;
    using System.Web.Services;

  3. Add the following method override to the class (replace soap.tcp://localhost/SampleServiceProxyTest with the URL for your service proxy):

    public override IAsyncResult BeginSend(SoapEnvelope envelope, AsyncCallback callback, object state)
    {
    envelope.Context.Addressing.From = new From(new Uri("soap.tcp://localhost/SampleServiceProxyTest"));
          return base.BeginSend(envelope, callback, state);

  4. Locate the public partial class Subscribe and apply the following attribute to it:

    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/eventing", IsNullable = false)]

  5. Locate the public partial class GetServiceHealthStateRequest and apply following attribute to it:

    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://SampleService/GetServiceHealthStateRequest.xsd", IsNullable = false)]

Create a Project to Instantiate and Use Your Proxy

Create a new project (console application or class library), and add a class to it that instantiates the proxy and makes calls to the methods of the proxy. When you make calls to the methods of the proxy, you must specify the correct parameters for the methods. The following class is an example implementation of such a class

Note. This is an example, and must be edited to implement the methods of your proxy and to use appropriate namespaces and URIs before it can be used):

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Services3;
using Microsoft.Web.Services3.Messaging;
using Microsoft.Web.Services3.Addressing;
using SOAPCLIENT = SampleServiceProxyTest.SoapClientProxy;
using System.Xml;
using System.Xml.Serialization;
using System.IO;


namespace SampleServiceProxyTest
{
    class MyReceiver : SoapService 
    {
        private SOAPCLIENT.SampleWebService soapWes = new SOAPCLIENT.SampleWebService();
      
        public MyReceiver()
        {
            Uri to = new Uri("soap.tcp://localhost/SampleServiceProxyTest");
            //TODO: Replace the above URI with the URI that you wish to have for
            //your receiver
            EndpointReference EPR = new EndpointReference(to);
            SoapReceivers.Add(EPR, this);
        }



        //Call Synchronous Provisioning method
        public void ProvisionSynch()
        {
            SOAPCLIENT.ProvisioningRequest provRequest = new SOAPCLIENT.ProvisioningRequest();
            provRequest.Data = "Provision this";
            SOAPCLIENT.ProvisioningResponse provResponse = soapWes.SampleProvisioningMethodSynch(provRequest);
        }


        // Call Asynchronous provisioning method
        public void TestProvisioningAsyc()
        {
            SOAPCLIENT.ProvisioningRequest provRequest = new SOAPCLIENT.ProvisioningRequest();
            provRequest.Data = "Provision this";
            soapWes.SampleProvisioningMethodAsynchAsync(provRequest);
        }


        // Define a method to receive asynchronous provisioning response
        [SoapMethod(" http://www.microsoft.com/ConnectedServices/WesAdapters/SampleAdapter/TestSampleProvisioning_AsyncResponse")]
        public void TestProvisioningAsyncResponse(SOAPCLIENT.ProvisioningResponse provisioningResponse)
        {
            if ( provisioningResponse != null)
            {
                //Process the response here.
            }
        }


    } //End Class


} //End Namespace

See Also

Show:
© 2014 Microsoft