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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Error when calling custom service

(0) ShareShare
ReportReport
Posted on by 2,017

Hi,

I called a customer service by C# and i'm getting this error:

System.ServiceModel.CommunicationException: 'An error occurred while receiving the HTTP response to
url/soap/services/XXCServices.


  • huijij Profile Picture
    19,813 on at

    Hi Sir,

    Do you also get the error if your url contains the name of the method on the service/class eg.

    url/.../create

  • Martin Dráb Profile Picture
    240,799 Most Valuable Professional on at

    Can you show us the code in question, please?

  • .. Profile Picture
    2,017 on at

    Hi Judy,

    Where do you suggest that to replace the service name ? in which URL?

    Hi Martin

    sessionInfo = ((XXCustService)channel).getDetails(new getDetails(callContext,request1));

    using AuthenticationUtility;
    using SoapUtility.XXCustServiceReference;
    using SoapUtility.UserSessionServiceReference;
    using System;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using CallContext = SoapUtility.XXCustServiceReference.CallContext;
    
    namespace SoapConsoleApplication
    {
        class Program
        {
            public const string UserSessionServiceName = "XXCustServices";
    
            [STAThread]
            static void Main(string[] args)
            {
                var aosUriString = ClientConfiguration.Default.UriString;
    
                var oauthHeader = OAuthHelper.GetAuthenticationHeader(true);
                var serviceUriString = SoapUtility.SoapHelper.GetSoapServiceUriString(UserSessionServiceName, aosUriString);
    
                var endpointAddress = new System.ServiceModel.EndpointAddress(serviceUriString);
                var binding = SoapUtility.SoapHelper.GetBinding();
    
                var client = new XXCustServiceClient(binding, endpointAddress);
                var channel = client.InnerChannel;
    
                getCusTDetailsResponse sessionInfo = null;
                CallContext callContext = new CallContext { Company = "AA" };
    
                var request1 = new XXCustReqContract();
                request1.AccountNum = "AA-000011";
                request1.DataArea = "AA";
                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                     requestMessage.Headers[OAuthHelper.OAuthHeader] = oauthHeader;
                     OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
                     sessionInfo = ((XXCustServce)channel).getDetails(new getDetails(callContext,request1));
                  
                }
    
                Console.WriteLine();
    
                Console.ReadLine();
            }
        }
    }

  • Martin Dráb Profile Picture
    240,799 Most Valuable Professional on at

    Your code looks good to me.

    Did you also change the setup in ClientConfiguration class?

    Does it work if you call a standard custom service instead of your own?

  • .. Profile Picture
    2,017 on at

    Hi Martin,

    yes i changed client config

    It works when i call another custom service that I own.

    One thing that I did, is that I changed the service group name but I did a build for it and changed the links accordingly (latest is what I'm showing you).. could this be the reason?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 475 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 399 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 374

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans