Reputation: 43
I'm trying to order SSL Certificates through Globalsign's API with Powershell, using the PVOrder method. URL is https://test-gcc.globalsign.com/kb/ws/v1/ManagedSSLService?wsdl and they have documentation here https://downloads.globalsign.com/acton/attachment/2674/f-092e/1/-/-/-/-/globalsign-mssl-api-user-guide-v2.3.pdf
The Powershell I'm using is very simple:
$URI = "https://test-gcc.globalsign.com/kb/ws/v1/ManagedSSLService?wsdl"
$result = (iwr $URI –infile "C:\Users\Administrator\Desktop\script_other\pvorder_soap.xml" –contentType "text/xml" –method POST)
And the XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xs:complexType name="PVOrder">
<xs:sequence>
<xs:element minOccurs="0" name="Request" type="tns:BmV1PvOrderRequest"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BmV1PvOrderRequest">
<xs:sequence>
<xs:element name="OrderRequestHeader" type="tns:OrderRequestHeader"/>
<xs:element name="OrderRequestParameter" type="tns:OrderRequestParameter"/>
<xs:element name="MSSLProfileID" type="xs:string"/>
<xs:element name="MSSLDomainID" type="xs:string"/>
...
</xs:complexType>
However I'm running into difficulty trying to figure out where the parameters are supposed to be defined. The XML design on most of the tutorials I've found looks different from the XML here. Some searching on google lead me to try putting the parameters at the end of the xml but before the which I tried so it looks like below, but the response didn't change at all.
...
<MSSLDomainID>test.com</MSSLDomainID>
</xs:complexType>
Any ideas on what I should be doing here? I have a decent amount of experience with Powershell but none with SOAP and none of the tutorials I've read seemed to have an answer for this.
Upvotes: 4
Views: 18584
Reputation: 1583
Instead of invoke web request use the utility built into Powershell called New-WebServiceProxy . Once you've done that you'll be able to see the methods and properties exposed by the webservice.
$Proxy = New-WebServiceProxy -Uri https://test-gcc.globalsign.com/kb/ws/v1/ManagedSSLService?wsdl
$Proxy | get-member
Name MemberType Definition
---- ---------- ----------
AddDomainToProfileCompleted Event Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1b_ws_v1_ManagedSSLService_wsdl.AddDomainToProfileCompletedEventHandler AddDomainToProfileCompleted...
AddMSSLDomainCompleted Event Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1b_ws_v1_ManagedSSLService_wsdl.AddMSSLDomainCompletedEventHandler AddMSSLDomainCompleted(System.Ob...
AddMSSLProfileCompleted Event Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1b_ws_v1_ManagedSSLService_wsdl.AddMSSLProfileCompletedEventHandler AddMSSLProfileCompleted(System....
ChangeSubjectAltNameCompleted Event Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1b_ws_v1_ManagedSSLService_wsdl.ChangeSubjectAltNameCompletedEventHandler ChangeSubjectAltNameCompl...
Disposed Event System.EventHandler
Using this proxy I was able to get the type from it in this means:
$Proxy = New-WebServiceProxy -Uri https://test-gcc.globalsign.com/kb/ws/v1/ManagedSSLService?wsdl -namespace globalsign -Class managed
$proxyType = $proxy.gettype().Namespace
$bmv1pvOrderRequest = New-Object("$proxyType.BmV1PvOrderRequest")
PS:\> $bmv1pvOrderRequest
OrderRequestHeader :
OrderRequestParameter :
MSSLProfileID :
MSSLDomainID :
SubID :
PVSealInfo :
ContactInfo :
SANEntries :
Extensions :
I chose to try and fill in contactinfo its type is Contactinfo so you have to create an object of that type and fill in the elements:
$C = new-object ("$proxyType.contactinfo")
$C.FirstName = 'thom'
$c.lastname = 'schumacher'
$c
FirstName LastName Phone Email
--------- -------- ----- -----
thom schumacher
Next you'll need to go through each item in the $bmv1pvOrderRequest and proxy in a new one of each of the types as necessary and then send the request to the Webservice.
$o = new-object ("$proxyType.orderRequestHeader")
$o
AuthToken
---------
PS:\> $p = new-object ("$proxyType.orderRequestParameter")
PS:\> $p
ProductCode :
BaseOption :
OrderKind :
Licenses :
Options :
ValidityPeriod :
CSR :
RenewalTargetOrderID :
TargetCERT :
SpecialInstructions :
Coupon :
Campaign :
$bmv1pvOrderRequest.OrderRequestHeader = $o
$bmv1pvOrderRequest.OrderRequestParameter = $p
$bmv1pvOrderRequest.ContactInfo = $c
Upvotes: 3
Reputation: 7338
You do not post WSDL. this describes what the XML is supposed to look like.
What you really need an example of what an XML should be & then you can just plug your variables into it. The documentation you've got describes the format of the order. doesn't actually have an example. I did a quick search, but could not find one for your specific need. technically with the WSDL you should be able to construct it.
This GlobalSign doco shows some examples of actual XML you post but is not for your specific API.
UPDATE: Found a service which analyzes WSDL and gives you example XML you can work with. Take a look at https://www.wsdl-analyzer.com/
Upvotes: 0