#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    PHP consuming .NET service protected by WS-Security


    Has anybody been successful connecting to a .Net service protected by WS-Security. I'm stuck on the signature creation. The signature that signs the SignedInfo element if it rings a bell with anyone. Scoured the net for a class, a library, etc -- nothing.

    Please let me know if anybody would like to share experience in this area.

    Thanks!

    EDIT: Does anybody know of an implementation in PHP of the PRF function from RFC2246?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0
    It appears there's nothing in PHP for this. I've posted on three different forums with no response. But there's light at the end of the tunnel...

    I came across an excellent blog entry by Yaron Naveh titled "Test drive the shiny new Wcf interop bindings". The forum is preventing me to post a link but it's on blogger.com. Basically though:

    1. Create a new Java project in Netbeans (a Java IDE).
    2. Right-click on the top node in the project, choose New, choose Web service client.
    3. Step 2 will create web method stubs from the WSDL link you had to specify in that same step 2. They will be under "Web Service References".
    4. Right-click on the first node under Web Service References and choose "Edit Web Service Attributes". Here you can specify the username and password if they are static OR choose dynamic and specify the name of the class that will do the username/password creation dynamically. See step 5.
    5. IF you generate your username/password dynamically, create a new Java class under your project (New -> Java Class) and modify this code with your username and password:

    for (int i = 0; i < callbacks.length; i++) {
    if (callbacks[i] instanceof NameCallback) {
    NameCallback nm = (NameCallback) callbacks[i];
    nm.setName(YOUR_USER_NAME);
    } else if (callbacks[i] instanceof PasswordCallback) {
    PasswordCallback pc = (PasswordCallback) callbacks[i];
    pc.setPassword(YOUR_PASSWORD);
    } else {
    throw new UnsupportedCallbackException(callbacks[i]);
    }
    }

    Yes, it's not PHP but at the point I'm in, I'm ready to try anything that works on Linux. So, I used Netbeans and the Java metro library to connect to the service. It worked!

    In order to minimize the amount of Java required, we're limiting our Java client to just connecting to the service, getting the data and outputting it in the JSON format for a PHP client to post-process.

    Hope this helps somebody.

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo