Credentials to web service

Last post 07-06-2009 3:05 AM by johnwsaunders3. 4 replies.

Sort Posts:

  • Credentials to web service

    05-26-2009, 4:57 AM
    • Member
      223 point Member
    • syamchk
    • Member since 12-29-2006, 1:03 PM
    • Hyderabad, India
    • Posts 90

    Hi,

    I am calling a java web service from .Net client.

     Credentials for soap request are present in an xml file as below.

     

    <xwss:SecurityConfiguration dumpMessages="true" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
      <xwss:UsernameToken name="username" password="password" />
      <xwss:RequireUsernameToken />
       </xwss:SecurityConfiguration>
     
    Sample java code for passing this xml file along with the request is:

                    //Set usernametoken            
                    String fileName = "./config/client-config.xml";
                    FileInputStream clientConfig = new FileInputStream(new File(fileName));
                    com.sun.xml.xwss.XWSSecurityConfiguration config = com.sun.xml.xwss.SecurityConfigurationFactory.newXWSSecurityConfiguration(clientConfig);
                    requestContext.put(XWSSecurityConfiguration.MESSAGE_SECURITY_CONFIGURATION, config);

    How can i achieve this in .Net? Any help will be thankful.

    Filed under:
  • Re: Credentials to web service

    06-02-2009, 10:15 AM

    Since this XML seems to be defined by Sun, i would suggest you ask Sun how to use it from languages other than Java.

    Can you post the WSDL to the web service (or a link to it)? Is there a "header" element in the WSDL for the operation you are trying to call?

    John Saunders
  • Re: Credentials to web service

    06-30-2009, 12:53 AM
    • Member
      223 point Member
    • syamchk
    • Member since 12-29-2006, 1:03 PM
    • Hyderabad, India
    • Posts 90

    Hi johnwsaunders3, Thanks for the reply. There is no header element in the WSDL. In general, how do we consume such kind of web service? I am very much new to WSE3.0.

    I tried this:

    UsernameToken token = new UsernameToken(strUserName, strPassword, PasswordOption.SendPlainText);
    SendService objSendService = new SendService();

    objSendService.SetClientCredential<UsernameToken>(token);

    //Set Policy
    Policy policy = new Policy();
    policy.Assertions.Add(new UsernameOverTransportAssertion());
    objSendService.SetPolicy(policy);

    string strResponse = objSendService.GetStatus();

    I am getting an Exception

    Here is the response message.

    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.generalException</faultcode><faultstring>WSDoAllReceiver: security processing failed (actions mismatch)</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">SIG-Traffic-Server-04</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

    Any help is greatly appreciated. Thanks in advance.

  • Re: Credentials to web service

    07-03-2009, 5:20 AM
    Answer
    • Member
      223 point Member
    • syamchk
    • Member since 12-29-2006, 1:03 PM
    • Hyderabad, India
    • Posts 90

    I got the solution.

    Write a class inheriting from SendSecurityFilter and overide the method SecureMessage(). Inside this method, encrypt and sign the Soap Message with X509SecurityToken.

  • Re: Credentials to web service

    07-06-2009, 3:05 AM

    Any header that is meant to be filled in by client code MUST be defined in the WSDL. How else would the client be expected to know that the header even exists?

    Also, I don't recall if we've discussed this - but you know that WSE is obsolete, right? You know that you should not be using it for any new development unless you have no choice at all?

    This has recently become even more obvious: see ASMX Web Services are a “Legacy Technology”.

    John Saunders
Page 1 of 1 (5 items)