Results 1 to 8 of 8

Thread: Send Username and Password to .net Web Service using Spring .NET

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Default Send Username and Password to .net Web Service using Spring .NET

    I am developing a .net application using Web Services, and the application is consuming them using Spring.Net WebServiceProxyFactory.

    I need to send to the web service the username and password of the user that is logged in to the application, consuming the web service.

    Reading some forum post (like this http://forum.springframework.net/showthread.php?t=4818) they seem to refer to an example that used to be in the spring documentation ( http://www.springframework.net/doc-l...bservices.html ), an example of how using SOAP headers for authentication using the WebServiceExporter and WebServiceProxyFactory, but the link to the file is broken.

    Also, the links in the post about Spring.Net and SoapHeaders by Bruno Baia (http://forum.springframework.net/showthread.php?t=3976) are broken too.

    Do you know a way that I can send the user credentials as a soap header using spring.net? Or any data (for example, a token ID that the web service will use later to get the user credentials).

    Thanks.

  2. #2
    Join Date
    Dec 2010
    Posts
    2

    Smile Send Username and Password to .net Web Service using Spring .NET

    Hi,

    I am facing the same problem since 2 days ago.

    Then I take source of Spring.Net, add in my Solution to know it better.

    I have found at CoreGetHandler.Invoke(this, new object[] {serviceType, context, context.Request, context.Response});

    Then I have discover the base {System.SystemException " This operation requires IIS integrated pipeline mode."}

    http://forums.iis.net/t/1158950.aspx

    http://forums.asp.net/p/1253457/2323117.aspx


    But as we are using Visual Studio and not using IIS yet . . .
    I have found this:

    Code:
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://model.iuni.com.br")]
        [System.Xml.Serialization.XmlRootAttribute("SecurityToken", Namespace = "http://model.iuni.com.br", IsNullable = false)]
        public class AuthenticationSoapHeader : SoapHeader
        {
            private string _devToken;
            private string _user;
            private string _pwd;
    
            public AuthenticationSoapHeader()
            {
            }
    
            public AuthenticationSoapHeader(string devToken)
            {
                this._devToken = devToken;
            }
    
            [System.Xml.Serialization.XmlTextAttribute()]
            public string ClientToken
            {
                get { return this._devToken; }
                set { this._devToken = value; }
            }
    
            [System.Xml.Serialization.XmlTextAttribute()]
            public string Usuario
            {
                get { return this._user; }
                set { this._user = value; }
            }
    
            [System.Xml.Serialization.XmlTextAttribute()]
            public string Senha
            {
                get { return this._pwd; }
                set { this._pwd = value; }
            }
        }
    And then put this into my web.config:
    Code:
    <configuration>
      <system.webServer>
        <httpProtocol>
          <customHeaders>
            <add name="CustomHeader" value="Namespace.AuthenticationSoapHeader" />
          <customHeaders>
        </httpProtocol>
      </system.webServer>
    </configuration>
    My Service class, that I am also using it as Fluorine Remoting inside Adobe Flex looks likes:

    Code:
        [RemotingService]
        [XmlInclude(typeof(VO.Paises))]
        public class Paises : Services.Interfaces.IPaises
        {
            public Repositorys.Auxil.IPaises paisesDAO;
            private static readonly ILog SysLOG = LogManager.GetLogger(typeof(Paises));
    
            public Services.AuthenticationSoapHeader AutenticaSoapHeader;
    
            [Transaction(ReadOnly=true)]
            public VO.Paises[] Lista()
            {
                if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Items.Contains("AutenticaSoapHeader"))
                {
                    AutenticaSoapHeader = (Services.AuthenticationSoapHeader)System.Web.HttpContext.Current.Items["AutenticaSoapHeader"];
                }
                if (!Security.Check(typeof(VO.Paises), AutenticaSoapHeader, "Lista"))
                { throw new Exception("Acesso Negado!"); //Access Denied
    }
    else
    {
                List<VO.Paises> listaPaises = new List<VO.Paises>(paisesDAO.Lista());
                return listaPaises.ToArray();
    }
            }
    My Spring configuration looks like:

    Code:
      <object id="PaisesService" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
        <property name="TargetName" value="PaisesSRV" />
        <property name="Namespace" value="http://www.myclientdomain.com.br/WebServices" />
        <property name="Description" value="Lista de Paises Cadastrados no sistema" />
        <property name="MemberAttributes">
          <dictionary>
            <entry key="Lista">
              <list>
                <object type="System.Web.Services.Protocols.SoapHeaderAttribute, System.Web.Services">
                  <constructor-arg name="memberName" value="AutenticaSoapHeader"/>
                </object>
              </list>
            </entry>
          </dictionary>
        </property>
      </object>
    That works for me.

    Tell me if you guys found another way to solve this problem.

    Regards,

    Elton Bicalho do Carmo

  3. #3
    Join Date
    Mar 2011
    Posts
    1

    Default

    Hello,

    Is there any update on this topic? Every place about using soapheaders with spring.net in the internet links to an unexistent example:
    http://opensource.atlassian.com/conf....rar?version=1

    Does anyone have this file or can give some clues on how to force the client to send a soap header?

    Regards,
    specific

  4. #4
    Join Date
    Sep 2010
    Posts
    4

    Default

    Hello,

    I have the same case of eltonbicalho, are there any other solutions?

    Thanks, bit

  5. #5
    Join Date
    May 2011
    Location
    173 Daniels Farm Rd, Trumbull, CT 06611
    Posts
    1

    Default

    Is there any other solution?????
    because I had the same problem last month, so reply me if you found any!!!
    Last edited by WavaShorthair6; 05-14-2011 at 11:25 AM.

  6. #6
    Join Date
    Oct 2005
    Location
    Toulouse, France
    Posts
    1,407

    Default

    Provided new download link in this thread


    - Bruno
    My english is as poor as my taylor is rich

  7. #7
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    2

    Default Trying to do the same thing with a self-hosted WCF service

    I'm trying to do the same thing with a self-hosted WCF service. Is this the same approach I should use? This is my first time using Spring.NET. I have inherited an existing application that used it and I have to maintain and extend it. Any recommendations on how to get my mind wrapped around this product? Thanks in advance for any and all assistance provided.

    Quote Originally Posted by Bruno Baia View Post
    Provided new download link in this thread


    - Bruno

  8. #8
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    2

    Default Trying to do the same thing with a self-hosted WCF service

    I forgot to mention that I am also wanting to use a CustomUsernamePassword Validator also. Where in the documentation would I finf this info?

    Quote Originally Posted by lagyossarian View Post
    I'm trying to do the same thing with a self-hosted WCF service. Is this the same approach I should use? This is my first time using Spring.NET. I have inherited an existing application that used it and I have to maintain and extend it. Any recommendations on how to get my mind wrapped around this product? Thanks in advance for any and all assistance provided.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •