Skip to main content

I have succesfully exposed a SmartObject as a webservice. When I try to access the webservice using SOAPUI it loads the service definition flawlessly but when I try to access the method it throws a 401 unauthorized error, no matter which account we use (even the admin account).

 

The method we performed these tests with just returns "Test", hardcoded, so no back-end systems are involved.

 

Any thoughts?

Thanks

Hi

 

401 unauthorized errors are usually related to Kerberos, please check your Kerberos configuration and settings.

 


Are you referring to exposing an existing Smartobject as a wcf/rest endpoint similar to the image below (Smartobject Services):


 


12926i3CB6C0FA5C9740E6.png


 


I am not familiar with SOAPUI, but how is the authentication method/mode specified.  Instead if you were to create a C# console app, add the service and test, do you see the same behavior?


 


Using WCF Endpoint to start the process


 


            StartProcessSMO_StartProcessSMOSvcClient client = new StartProcessSMO_StartProcessSMOSvcClient();


            // Use the 'client' variable to call operations on the service.


 


            StartProcessSMO_StartProcessSMO processSMO = new StartProcessSMO_StartProcessSMO();


            processSMO.Folio = "fromConsoleApp";


            processSMO.Priority = "0";


 


            client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;


 


            client.StartProcessSMO_StartProcessSMOSvc_StartProcess(processSMO);


 


            // Always close the client.


            client.Close();


 


https://help.k2.com/onlinehelp/k2blackpearl/devref/4.6.7/webframe.html#URIs_for_WCF.html


 


 


“POST” to a rest service


            Uri address = new Uri("http://k2.denallix.com:8888/SmartObjectServices/rest/Workflow/StartProcessSMO/StartProcessSMO/StartProcessSMO Process Instances/Start Process");


 


            // create the XML Returned variable


            string XML_Return;


 


            // Create the web request


            HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;


 


            // Assign Credentials


            request.Credentials = CredentialCache.DefaultCredentials;


 


            // Set type to POST


            request.Method = "POST";


            request.ContentType = "application/xml";


 


            // Create the data we want to send


            string SO_Create_POST = "<StartProcessSMO_StartProcessSMO><Folio>Rest Call</Folio><Priority>1</Priority></StartProcessSMO_StartProcessSMO>";


 


            StringBuilder data = new StringBuilder();


            data.Append(SO_Create_POST);


 


            // Create a byte array of the data we want to send


            byte;] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());


 


            // Set the content length in the request headers


            request.ContentLength = byteData.Length;


 


            // Write data


            using (Stream postStream = request.GetRequestStream())


            {


                postStream.Write(byteData, 0, byteData.Length);


            }


 


            // Get response


            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)


            {


                // Get the response stream


                StreamReader reader = new StreamReader(response.GetResponseStream());


 


                // assign resonse the XML Returned variable


                XML_Return = reader.ReadToEnd();


            }


 


https://help.k2.com/onlinehelp/k2blackpearl/devref/4.6.7/webframe.html#Using_K2_Web_Services_with_ASP.NET_Applications_REST.html


Reply