web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

SOAP - OASIS WSS integration with Service Reference

(0) ShareShare
ReportReport
Posted on by 3,850

Hello.

I have built a sucessful web services with this approach:

  1. New VS Project.
  2. Add Service Reference (WSDL) url.
  3. Deploy og Server and Client
  4. Add to AOT

All basic things and success. 

I have wrote a code in X++ who expose this services and all that, the code is OK as far as it goes.

The Propblem:


In the manual from the service provider they handle security login using X509 Token and the Username Token (Visual Studio things).

As it is described in the manual:

"Each call to the service should include a UserNameToken in accordance with the OASIS WSS UsernameToken Profile 1.0. The token should include the Username and Password tags. The Password@Type attribute references by default the URI „...#PasswordText“ and the password should be sent as clear text."

And they give an example of a code (envelope):

<S11:Envelope xmlns:S11="..." xmlns:wsse="...">
<S11:Header>
...
  <wsse:Security>
   <wsse:UsernameToken>
    <wsse:Username>MyUserName</wsse:Username>
    <wsse:Password>My1ongA$ndDlff9ltP%$$phr$se</wsse:Password>
   </wsse:UsernameToken>
  </wsse:Security>
...
</S11:Header>
...
</S11:Envelope>

Obviously I need to get to the username and the password into AX user interface, either to store it there or to bring up as a dialog when user do some actions. But How can I do it?

I have seen several examples: One have used .NET 2.0 framework SDK (who is old version) and use wsdl.exe to create .NET Assembly and add that to Reference in the AOT.

Can anyone tell me what is the approach to implement it in AX so I can change the username and passw through AX UI?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    I'm again not sure what you need from us. You created a thread about "SOAP" and "service reference", showed some code related to web service authentication and then asked a question about AX user interface.

    Could you please explain once more what problem are you trying to solve in the moment? For example, if you need help with an AX form, please stop mixing SOAP, certificates, wsdl.exe and such things into the problem.

    It's try to address your last sentence, at least:

    Well, you need some UI element anyway to allow users to execute the service. Maybe you already have something and you just need to extend it - you should tell us so. You obviously need a form to get input from users (a dialog is a type of form constructed at runtime). Personally I would prefer using a SysOperation class - it shows a dialog on client and then executes some logic on server and you can choose from several execution mode (synchronous/asynchronous/batch).

  • Sandri Profile Picture
    3,850 on at

    Hi Martin and sorry for this inconvinience.

    First of all, I create a webservice from WSDL, to Visual Studio and import from AX.

    In this WSDL are some transactions that request authentications, so as I understandi it from the manuals this authentication envelope with username and password are always sent with the action.

    So if user does some action in User Interface in AX, for ex. do bank transaction, that action is in some WSDL URL and have been implemented to AX all the way.

    But this authentication envelope is (as far as I understand the manual) always sent with the transaction, to be ensure that the user have right privelges to do that transaction.

    This authentication code is issued in XSD file, and as I told you before I don't find anything in WSDL URL for this authentication, there is no action in WSDL like login or something like that. There is though SOAP Channel and SOAP Client in WSDL URL's, but I'm not sure if I need to use it with this authentication envelope, or not.

    What I need is some workflow who send this authentication with each WS request.

    If I have Soap Channel, Soap Client in the WSDL, should I combine it with this authentication envelope sonehow?

    If the authentication is just issued in XSD, then should I parse it through by XSL and combine the transaction in AX, so the authentication will be sent with the request?

    Therefore: In order to insure message integrity all messages are signed using a private key. This means that it is impossible1 to modify the message without the receiver knowing it. Both the request (for the client) and response (for the server) message are signed. SSL is used to enforce message confidently, that is only the server and the client can read messages. WS‐Security describes how to attach signature and encryption headers to a SOAP message. WS‐Security also describes how to attach security tokens. In B2Bws we use the X.509 Token and the Username Token.

    "At the end of the day" I need to access this authentication envelope, so user can store username and password in AX through dialog box as u suggest it.

    But because I can't see in the WSDL URL some action that allows me to send this information with the request, I need to know how to do it in seperate way and combine it with the request.

  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    Well, this doesn't look like a simplified description with unrelated stuff removed. :-/

    From how you're using some terms and acronyms, it seems to me that you don't orient yourself very well in how web services and WCF work. If it's so, it's the major problem that you should address if you want to use them.

    For example, authentication is not implemented separately for every service; it's handled at a lower level by bindings.

    Now it looks that you want to ask about web service security, but you mentioned several different concepts. It seems to me that you want to implement transport-level security via SSL, sign the message with a client certificate and also do something with ausername and password, nevertheless I'm not really sure that I extracted your requirements correctly.

    Can you please confirm in a few sentences whether your current problem is web service authentication and what's the part you need help with?

    Also, if your problem is really about web service authentication, a forum about Dynamics AX isn't probably the best place to ask. (I would try Windows Communication Foundation, Serialization, and Networking forum on MSND.)

  • Sandri Profile Picture
    3,850 on at

    Hello Martin I will try to confirm in few sentence what I want. I have search a lot on the internet for answers so I will tell you also my thought of solution.

    I have created a VS-Project ONLY with service refernece (WSDL) URL and import to AX, no cs files, no C# code, just nothing else than just the Service Reference.

    So when I develop a AX Class, to communicate with the service, the request is sent in xml document. But in that document is an "envelope" in the header, you know, an area who in this chase store username and passw, but also can store cookies and more.

    So the username and password in the "envelope" in the header is just a plain text. The webservice provider have write a C# demo code for that authentication.

    What I want, if it is possibility to create in AX a variables with username and passw (in the C# demo solution it's just pure strings variables) so I can Imagine that I can just create a two strings wariables with username and password in AX, and add that information to the "envelope" in the header of the XML document who is created in AX and sent as a request for the service.

    The Service provider have also issued an XSD file for this "envelope" so if I convert it into XML I will probably get the XML code who is needed to store the username and passw, so I can put the strings variables in the right place there - and all that codeblock to the header section.

    So understand me now? Each XML request have an "envelope" in the header area, and I want to put right envelope in the header section, if I can do it just in AX instead of using C# code and call him from AX.

    So clear and straight - add the envelope with username and passw in text from strings variables in the header section before the xml document is sent as a service request.

  • Verified answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    The "envelope" is a message header. You can set headers in .NET, of course, but concrete implementation depends on what you need to achieve. There are really many options in this area (just look at Common Security Scenarios on MSDN).

    A simple example using name and password:

    var endPoint = new EndpointAddress(...));
    
    var binding = new WSHttpBinding();
    binding.Security.Mode = SecurityMode.Message;
    binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
    
    var client = new MyServiceClient(binding, endPoint);
    client.ClientCredentials.UserName.UserName = ...;
    client.ClientCredentials.UserName.Password = ...;

    You can use .NET classed directly from X++, if you want, although you can do many things more easily in C# so it's often worth to add some code to the library with the service reference, which you need anyway.

  • Sandri Profile Picture
    3,850 on at

    Hi martin

    thanks for that.

    I will probably use the demo code from the service provider, and do some modification there.

    Then it should work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans