Announcements
I created the following class for service "CCService" and created a service group called "CCServiceGroup"
class CC { public ContractResponse createCust(ContractRequest cust) { CustTable custTable; ContractResponse response = new ContractResponse(); ttsBegin; custTable.AccountNum = custDetails.CustomerAccount(); custTable.CustGroup = custDetails.CustGroup(); custTable.insert(); ttscommit; return response; } } //ContractResponse returns string success //ContractRequest has accountNum and CustGroup parameters
I added the clientId in D365FO
I took the code for AuthenticationUtility, SoapUtility and SoapConsoleApplication from github: https://github.com/microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples
Now in the code for SoapConsoleApplication, how i'm going to call the service above?
Here's the code for SoapConsoleApplication
using AuthenticationUtility; using SoapUtility.UserSessionServiceReference; using System; using System.ServiceModel; using System.ServiceModel.Channels; namespace SoapConsoleApplication { class Program { public const string UserSessionServiceName = "UserSessionService"; [STAThread] static void Main(string[] args) { var aosUriString = ClientConfiguration.Default.UriString; var oauthHeader = OAuthHelper.GetAuthenticationHeader(); var serviceUriString = SoapUtility.SoapHelper.GetSoapServiceUriString(UserSessionServiceName, aosUriString); var endpointAddress = new System.ServiceModel.EndpointAddress(serviceUriString); var binding = SoapUtility.SoapHelper.GetBinding(); var client = new UserSessionServiceClient(binding, endpointAddress); var channel = client.InnerChannel; UserSessionInfo sessionInfo = null; using (OperationContextScope operationContextScope = new OperationContextScope(channel)) { HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers[OAuthHelper.OAuthHeader] = oauthHeader; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; sessionInfo = ((UserSessionService)channel).GetUserSessionInfo(new GetUserSessionInfo()).result; } Console.WriteLine(); Console.WriteLine("User ID: {0}", sessionInfo.UserId); Console.WriteLine("Is Admin: {0}", sessionInfo.IsSysAdmin); Console.ReadLine(); } } }
when i ran this code i got this error on this line: sessionInfo = ((UserSessionService)channel).GetUserSessionInfo(new GetUserSessionInfo()).result;
The message with Action 'schemas.microsoft.com/.../GetUserSessionInfo' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
How to solve this error and how to call my service ?
Sorry i meant NameSequence, how can i pass this value?
i can't put EnumMemberAttribute in my D365 class, so what u are saying is i should make the request of type string? and pass string in c#? and if it wasn't extensible true, it would have worked normally?
i should call the validate write before the insert right? i thought this gets called automatically before inserting.
Hi Junior AX,
Looks like there is some kind of issue in D365 with Extensible enums and D365 doesn't generate service definition correctly. But you can always use a string and convert string to enum value via symbol2Enum function.
community.dynamics.com/.../enum-problems-in-d365fo-when-creating-custom-services
EDT NameAlias has type string, not sure how it was converted to int64. Are you using this EDT in the member parm method? Have you updated service in C# after you added a new member?
If you want to be sure that you filled all important fielde, call custTable.validateWrite() and check the output of the method.
Hi Sergie,
can i ask another thing related to this service.
if i added to the request class, DirPartyType and NameAlias DataMemberAttributes ( as u knw dirPartyType is an enum, and NameAlias is int64).
[DataMemberAttribute] public DirPartyType DirPartyType(DirPartyType _dirPartyType = dirPartyType) { dirPartyType = _dirPartyType; return dirPartyType; }
In c# code, when i want to fill, they type or NameAlias, is there a way not to fill like a string?
request.DirPartType = "Person"
so in that case, the only way is in the service class to check:
if (request.DirPartyTpe() == DirParType::Person || request.DirPartyTpe() == DirParType::Organzition)
{
}
else
{
throw error (" not valid");
}
??
or is there a way to do to be able not to hard code the type in C#? also what about NameAlias how i'm going to fill it in c#?
i thought maybe in c# i could say if the type is person then fill the fields related to dirPerson and if Organization then fill organization fields?
also when creating a customer, is there other important tables i need to fill other than customer, and dirPartyTable?
Hi JuniorAX,
Here is information about number sequences docs.microsoft.com/.../number-sequence-overview
In use - mean that number sequence is in use (i think it's switched to yes, as soon as the first number is allocated from number sequence)
yeah it works now thanks alot, btw what does inUse flag and continuous flag means?
Hi JuniorAX,
Try to unmark "Manual" checkbox from number sequence.
yeah the debug worked, i had to attach to iisexpress first then go to SoapConsole and start new instance thank you.
As for the number sequence, yes i do have existing customers and several companies but when calling the service i specified in the call context that i want a certain company. (the scope in setup is company)
Right now if i try to create customer manually from the environment, it doesn't give me a numberSeq i have to fill it by hand so it seems the setup is wrong somehow right?
Hi JuniorAx,
According to the set up next number is 1. Do you have any existing customers in the system? Do you have several companies in your environment?
You can debug your service in D365 as you usually debug any x++ code. Soap request can be done from another VS instance.
Hi,
1. it's set up
2. it's not continuous
3. what do u mean by this?
here are my settings, is there anything i need to do to make number seq works?
André Arnaud de Cal...
294,079
Super User 2025 Season 1
Martin Dráb
232,860
Most Valuable Professional
nmaenpaa
101,158
Moderator