Announcements
Using SOAP client (SoapUI 5.6.0) we are trying to make a simple call to the ERP system to pull some data, for example, purchase invoice in our case. We imported WSDL and opened a generated request, trying to make a call with default values (basically all the filters are absent so we expect to get all entries), but getting a message: BadContextToken. The message could not be processed. This is most likely because the action 'http://schemas.microsoft.com/dynamics/gp/2010/01/IPurchaseOrderTransactions/GetPurchaseInvoiceList' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
What is really a security context and how to use it properly? do you have an example of some basic request to get any entity that includes this security context?
Any solution for this issue? we also wanted to connect GP web services endpoint from Java, we are getting the same security token issue. Could you please advise without using C# .Net are we able to connect?
Andrew,
I'm afraid we don't maintain a library of XML calls to GP Web Services endpoints. We really only support it using .NET calls to a referenced API URL via Visual Studio. This is where I'm afraid we're not going to be able to assist you with what SoapUI seems to need. If you setup a .NET project in Visual Studio I'd imagine you should be able to capture or output the XML that is being serialized there and try to use that in this other tool.
Lucas
Hi Andrew
Are you using .Net to call the web service?
Regards
David
Lucas, Derek,
I have GP WebServices installed and running. I’m trying to invoke sample service (GetCustomersList action), but getting this error:
-*-*-*----------------------------------------------------------------------------------------------------------------------------------------
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="schemas.xmlsoap.org/.../s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">The message could not be processed. This is most likely because the action 'schemas.microsoft.com/.../GetCustomerList' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.</s:Text>
</s:Reason>
</s:Fault>
Based on my research it means that WSS headers required by the service are not provided, or incorrect.
Native endpoint is set to use wsHttpBinding with the following definition (default from WSBinding config file):
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
-*-*-*----------------------------------------------------------------------------------------------------------------------------------------
I tried to use these headers without any luck:
<soap:Header>
<wsse:Security mustUnderstand="1" xmlns:wsse="docs.oasis-open.org/.../oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-5700630" xmlns:wsu="docs.oasis-open.org/.../oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>someUser</wsse:Username>
<wsse:UserTokenID>somePassword</wsse:UserTokenID>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
-*-*-*----------------------------------------------------------------------------------------------------------------------------------------
Question:
What should be the SOAP header structure in order to meet this requirement and properly authenticate with the service?
I have a Windows user account with proper permissions to access Web Services.
Could somebody share an XML example?
I need a plain XML example, not a code to generate them.
Please help.
Andrew, why don't you try to use Power Platform?
You can create custom connectors too.
I'm afraid I've never heard of people having much luck using SoapUI to make calls to GP Web Services. My team did put some time into researching this back in 2019, but never found a good solution. It isn't something we can technically support.
From the couple partners/customers I've heard trying to use this it sounded like they could only use the older legacy endpoint for GP Web Services. I also think that when they tried to call some of our APIs via SoapUI they found some information SOAP needed was missing from the API.
The supported method for calling GP Web Services would be a C# application in Visual Studio.
Andrew, I will NOT be any on help with this as I do not do any work with SOAP.
Derek, thanks a lot for your answer. We checked the samples on the official documentation page, for example to get list of customers.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; CustomerCriteria customerCriteria; CustomerSummary[] customerSummaryList; LikeRestrictionOfstring stateRestriction; // Create an instance of the service DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); // Create a context with which to call the service context = new Context(); // Specify which company to use (sample company) companyKey = new CompanyKey(); companyKey.Id = (-1); // Set up the context context.OrganizationKey = (OrganizationKey)companyKey; // Specify the criteria for the customer summaries to retrieve stateRestriction = new LikeRestrictionOfstring(); stateRestriction.Like = "%ND%"; customerCriteria = new CustomerCriteria(); customerCriteria.State = stateRestriction; // Retrieve the list of customer summaries customerSummaryList = wsDynamicsGP.GetCustomerList(customerCriteria, context); // Display the number of customers matching the criteria MessageBox.Show("North Dakota customers: " + customerSummaryList.Length.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }
But in that example we don't see 2 things:
1. Where URL is specified
2. How to pass security (usually at least some header is used which is calculated based on login/password)
We are using Java to make the integration, C# code isn't suitable to us, hence we wanted first to try to make a raw request using plain xml to understand which properties we have to use.
Using WSDL we pulled the API using SOAPUI, but every request we make returns us BadContextToken and we are trying to elaborate what we are doing wrong.
Thank you in advance if you have nay ideas.
In both the Web Services SDK and eConnect install directories, there are samples you can look at to get an idea of how to setup the code needed to, in this example, pulling a purchase invoice list from Dynamics GP.
If you haven't, I'd start with that and then modify accordingly. This is the best answer we'd have on 'how to use it properly'.
Thanks
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator