New-WebserviceProxy issues, when there is no wsdl or amsx endpoint?

Welcome Forums General PowerShell Q&A New-WebserviceProxy issues, when there is no wsdl or amsx endpoint?

Viewing 1 reply thread
  • Author
    Posts
    • #210642
      Participant
      Topics: 1
      Replies: 2
      Points: 19
      Rank: Member

      https://service5.ultipro.com/services/LoginService

      There is one other SOAP service we actively use to disable users on that platform, and new-webserviceProxy works fine when you just point it at the wsdl address, find the method you wanna use, gather your parameters and use that method….but as you can see, the one above doesnt have the wsdl in the endpoint. I tried to see if i could get lucky and “/?wsdl” in the url, but no luck. I did notice a wsdl address in the xml response of the link above, but when i attempt to use that address, says the Object ref not set to an instance of an object… see last snippet.

       

      Here it just fails when creating the object, and im not sure the actual error message or why.

       

      SysinternalsSuite> [03/16/2020 14:21:19]> $URI="https://service5.ultipro.com/services/LoginService"
      
      SysinternalsSuite> [03/16/2020 14:24:44]> $Proxy = New-WebserviceProxy $URI -Namespace x
      New-WebserviceProxy : Exception has been thrown by the target of an invocation.
      At line:1 char:10
      + $Proxy = New-WebserviceProxy $URI -Namespace x
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (:) [New-WebServiceProxy], TargetInvocationException
      + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Microsoft.PowerShell.Commands.NewWebServiceProxy

      Using the only wsdl address i can find in the first url above, then fails for null object i guess

      SysinternalsSuite> [03/16/2020 14:27:43]> $URI="https://service5.ultipro.com/services/LoginService?wsdl=wsdl0"
      
      SysinternalsSuite> [03/16/2020 14:29:17]> $Proxy = New-WebserviceProxy $URI -Namespace x
      New-WebserviceProxy : Object reference not set to an instance of an object.
      At line:1 char:10
      + $Proxy = New-WebserviceProxy $URI -Namespace x
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (:) [New-WebServiceProxy], NullReferenceException
      + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewWebServiceProxy
      • This topic was modified 2 months, 1 week ago by Dogbyte.
    • #210651
      Participant
      Topics: 1
      Replies: 2
      Points: 19
      Rank: Member

      Here is a snippet of an example they give in c#, tried to port it to powershell, but im missing a .net assembly, and im not sure i can load those where im gonna run this scheduled task, so not sure its worth the effort chasing it down.

      But to someone that can read C# better thanĀ  me, might be able to glean how I might do the same thing in powershell, and this is just the Auth portion, after i get back a token, i think it will all make sense and just work once i get access to the object that houses all the operation methods for the specified web service endpoint.

      I appreciate anyone taking a look.

      The following code is an example of authenticating to your UltiPro data in a console application. You can copy the entire contents to a C# console application and update the following values and have an operable application.

      UserName = "YOUR SERVICE ACCOUNT OR WEB USER NAME ",
      Password = "YOUR PASSWORD",
      UserAPIkey = "YOUR USER API KEY",
      CustomerAPIkey = "YOUR CUSTOMER API KEY"

      namespace ConsoleSample
      {
      using System;
      using System.ServiceModel;
      using System.ServiceModel.Channels;

      using ConsoleSample.LoginService;

      public class Program
      {
      internal static void Main(string[] args)
      {
      // Setup your user credentials:
      const string UserName = "";
      const string Password = "";
      const string UserApiKey = "";
      const string CustomerApiKey = "";

      // Create a proxy to the login service:
      var loginClient = new LoginServiceClient("WSHttpBinding_ILoginService");

      try
      {
      // Submit the login request to authenticate the user:
      string message;
      string authenticationToken;

      AuthenticationStatus loginRequest =
      loginClient
      .Authenticate(
      CustomerApiKey,
      Password,
      UserApiKey,
      UserName,
      out message,
      out authenticationToken);

      if (loginRequest == AuthenticationStatus.Ok)
      {
      // User is authenticated and the authentication token is provided.
      Console.WriteLine("User authentication successful.");
      }
      else
      {
      // User authentication has failed. Review the message for details.
      Console.WriteLine("User authentication failed: " + message);
      }

      loginClient.Close();

      Console.WriteLine("Press a key to exit...");
      Console.ReadKey(true);
      }
      catch (Exception ex)
      {
      Console.WriteLine("Exception: " + ex);
      loginClient.Abort();
      throw;
      }
      }

      XML Examples

      Authentication Service (http://<address>/services/LoginService)
      The Authentication Service is required to get the Token needed for all Core Web Service Calls.
      The following code is an XML example of authenticating to your UltiPro data. You can copy the entire contents and update the values in the request. The response example shows how a successful response will be formatted.

      Login Method Request

      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
      <s:Header>
      <a:Action s:mustUnderstand="1">http://www.ultipro.com/services/loginservice/ILoginService/Authenticate</a:Action>
      <h:ClientAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">CAK</h:ClientAccessKey>
      <h:Password xmlns:h="http://www.ultipro.com/services/loginservice">PASSWORD</h:Password>
      <h:UserAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">USER API KEY</h:UserAccessKey>
      <h:UserName xmlns:h="http://www.ultipro.com/services/loginservice">USERNAME</h:UserName>
      </s:Header>
      <s:Body>
      <TokenRequest xmlns="http://www.ultipro.com/contracts" />
      </s:Body>
      </s:Envelope>

      Login Method Response

      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
      <s:Header>
      <a:Action s:mustUnderstand="1">http://www.ultipro.com/services/loginservice/ILoginService/AuthenticateResponse</a:Action>
      </s:Header>
      <s:Body>
      <TokenResponse xmlns="http://www.ultipro.com/contracts">
      <Status xmlns="http://www.ultipro.com/services/loginservice">Ok</Status>
      <StatusMessage i:nil="true" xmlns="http://www.ultipro.com/services/loginservice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
      <Token xmlns="http://www.ultipro.com/services/loginservice">LOGIN TOKEN</Token>
      </TokenResponse>
      </s:Body>
      </s:Envelope>

Viewing 1 reply thread
  • You must be logged in to reply to this topic.