Webservice & web.config-soap extension-pls help

Hi ,

i have a soapextension & soapextensionattribute classes created and they are successfully used in the webservice .

[WebMethod]
[EncryptionExtension(Encrypt=EncryptMode.Request)]
public string HelloWorld()
{ return "Hello World"; }

I have created the class library for this extension classes and i referenced this dll to the client web app which has the proxy class writen by me(not by wsdl) .It also works nice.

webclient-sample
---------

[System.Web.Services.WebServiceBindingAttribute(Name="HelloWorldSoap", Namespace="http://tempuri.org/")]
public class Cls1:System.Web.Services.Protocols.SoapHttpClientProtocol
{

public Cls1()
{
this.Url="http://localhost/devsena/AceService/service_Traceext.asmx";
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/HelloWorld", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[EncryptionExtension(Decrypt=DecryptMode.Request)]
public string HelloWorld()
{

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));
}


Then i decided to use web.config file to configure the soapextension classes am bit confused .I surfed the net and am not getting what i look for .

Please tell me

1.how can i use web.config file to configure soapextensions and how do i specify the type attribute ,does it refer name of the "Extension dll or namespace.class name "

<soapExtensionTypes>
<add type="EncryptionExtension" priority="1" group="0" />
</soapExtensionTypes>


2.if i configure my webclient web.config file ,what are all the lines(from my above sample) that can be eliminated by the web.config file

examples are given in the articles as the theoritical point of view and seems difficult to find real exmaples for this .Please help me Gurus and make me clear .

Thanks & Regards

Raghuraman.C





Answer this question

Webservice & web.config-soap extension-pls help

  • sam-pan

    Raghu,

    The soap extension class resides in the same assembly with the webservice.... that means, do you have the soap extension class added to the web service project

    I suggest you to put it in a separate assembly and use the format Namespace.Type, Assembly as shown in my previous post. But don't forget to add the assembly name in the type attribute.

    Rgds

    Rodrigo


  • Girkers

    Raghuraman,


    1. The type attribute as usual contains the full type name:

    type="Namespace.Class, Assembly, Version=version, Culture=culture, PublicKeyToken=key"

    for example:

    type="WS.Utils.Extensions.MyExtension, WSUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"


    2. There's no need to add anything in the client to use a SoapExtension.... only the server must be configured as shown.

    Hope it helps
    Rgds
    Rodrigo

  • tmk7

    Rodrigo

    Thx for your suggestion .it worked .

    <add type="namespace.classname,"assemblyname",..../>

    This line was great and it worked .

    Raghu



  • TonyX852

    Dear Rodrigo ,

    i tried as u said but getting the exception in web.config as

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: The 'type' attribute must be set to a valid type name.

    Source Error:

    Line 5: <webServices>
    Line 6:   <soapExtensionTypes>
    Line 7:     <add type="abc.EncryptionExtension" priority="1"
    Line 8:          group="0" /> 
    Line 9:   </soapExtensionTypes>

    this is my change made as you said ,

    My web.config has the following extension for webservice

    <system.web>
    <webServices>
    <soapExtensionTypes>
    <add type="abc.EncryptionExtension" priority="1"
    group="0" />
    </soapExtensionTypes>
    </webServices>

    -----------------------
    in a class file ,i have the above type declared as
    -------------------------------------------------------
    namespace abc
    {
    public class EncryptionExtension : SoapExtension
    {
    Stream oldStream;
    .....
    ......
    }
    [AttributeUsage(AttributeTargets.Method)]
    public class EncryptionExtensionAttribute : SoapExtensionAttribute
    {
    private int priority;
    .....
    .....
    }
    }

    -------------------------------------------------------

    and my webmethod simply has ...(believing that no extension is needed in a web method as the web.config has)

    [WebMethod]

    public string HelloWorld()

    { return "Hello World";}

    Please guide where i mistake...

    Thanks&Regds

    Raghu



  • Webservice & web.config-soap extension-pls help