Soap Service Authentication

I am testing connecting to the SOAP Web Service via a .NET application and all attempted requests get a 405 Method Not Found response. I think this may be because i am using basic authentication which is no longer an option for the SOAP service?

The guide suggests setting up OAUTH authentication however this is not an option for me since the sage x3 instance is not public facing.

Can anyone confirm if it is the case basic authentication will not work and if there is a way to use OAUTH without making the sage instance public facing?

Parents
  • What version of X3 are you on, and what version of .net are you using?  X3 uses basic authentication for the SOAP web services since version 8.  I believe the way to call X3 web services from SOAP is difference from .net Core, but if you are using a standard Console/WinForms/Web application, it should work with basic authentication.

  • in reply to Denise Hartman

    I can successfully get a list of customer using the test tool within x3 however using the same values in an equivalent call from a .net application always returns 405.

    static string _x3WSUr1 = "https://x3erpv12sqlvm.local:8443/soap-wsdl/syracuse/collaboration/syracuse/CAdxWebServiceXmlCC?wsdl";
    static string _publicName = "AOWSEXPORT";
    static CAdxWebServiceXmlCCService _x3WebService = new CAdxWebServiceXmlCCServiceBasicAuth();
    static CAdxCallContext _callContext = new CAdxCallContext();
    static CAdxResultXml _resultXML = new CAdxResultXml();
    
    static void Main(string[] args)
    {
    	_callContext.codeLang = "ENG";
    	_callContext.poolAlias = "ADC";
    	_callContext.requestConfig = "adxwss.trace.on=off&adxwss.trace.size=16384&adonix.trace.on=off&adonix.trace.level=3&adonix.trace.size=nadxwss.optreturn=1SON&adxwss.beautify=true";
    	_x3WebService.Url = _x3WSUr1;
    	_x3WebService.Credentials = new NetworkCredential("...", "...");
    	_x3WebService.PreAuthenticate = true;
    	_x3WebService.Timeout = 6000000;
    	
    	ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; // fix for trust relationship error
    
    	CAdxParamKeyValue[] objectKeys = new CAdxParamKeyValue[1];
    
    	_resultXML = _x3WebService.query(
    		callContext: _callContext,
    		publicName: "BPC",
    		objectKeys: objectKeys,
    		listSize: 100);
    }

  • in reply to Graeme Faulkner

    You need to add the basic authentication to the request header.  Below is a blog post with details on how to add the authentication header to the web request in .net

    www.rklesolutions.com/.../5-days-sage-x3-web-services-v12-day-4

Reply Children
  • in reply to Denise Hartman

    Yes I followed that guide to produce the code sample above, it looks like that will be very useful once I can successfully connect.

    The example above is using the recommended custom version of CAdxWebServiceXmlCCService ( CAdxWebServiceXmlCCServiceBasicAuth )

    static CAdxWebServiceXmlCCService _x3WebService = new CAdxWebServiceXmlCCServiceBasicAuth();

    The custom class is correct as far as i can see. 

    using ConsoleApp.X3WebService;
    using System;
    using System.Net;
    using System.Text;
    
    namespace ConsoleApp.App_Code
    {
        public class CAdxWebServiceXmlCCServiceBasicAuth : CAdxWebServiceXmlCCService
        {
            protected override WebRequest GetWebRequest(Uri uri)
            {
                HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);
                NetworkCredential credentials = Credentials as NetworkCredential;
    
                if (credentials != null)
                {
                    string authInfo = "";
                    if (credentials.Domain != null && credentials.Domain.Length > 0)
                    {
                        authInfo = string.Format(@"{0}\{1}:{2}", credentials.Domain, credentials.UserName, credentials.Password);
                    }
                    else
                    {
                        authInfo = string.Format(@"{0}:{1}", credentials.UserName, credentials.Password);
                    }
                    authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                    webRequest.Headers["Authorization"] = "Basic " + authInfo;
                }
    
                return webRequest;
            }
        }
    }