Previously when working with calling SOAP web services from PowerShell life's been easy. Run $myProxy = New-WebServiceProxy -Uri 'https://example.com/some/web/service.aspx?wsdl'
, then all actions are magically available on the $myProxy
object.
However, I've recently agreed to help implement a quick script which allows us to send data to the SII web services detailed here: https://www.agenciatributaria.es/AEAT.internet/en_gb/Inicio/Ayuda/Modelos__Procedimientos_y_Servicios/Ayuda_P_G417____IVA__Llevanza_de_libros_registro__SII_/Ayuda_tecnica/Informacion_tecnica_SII/WSDL_de_los_servicios_web/WSDL_de_los_servicios_web.shtml
The non-production web service I'm connecting to should be: https://www7.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP (i.e. received invoices from the previous link). However, attempting to connect to that URL fails.
I've found a workaround where I can create a proxy using the URI: https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroFactEmitidas.wsdl. However, the generated proxy does not give me the actions I'd expected to see. Looking at the underlying WSDL it seems that there are multiple ports specified; some for production, another for test. I want to ensure that I only connect to the test service.
Question
How do I ensure that I only connect to the test service?
i.e. For WSDL: https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroFactEmitidas.wsdl
...how do I ensure I only connect to port SuministroFactEmitidasPruebas
?
My Code At Present
$uri = 'https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroFactEmitidas.wsdl'
$certificate = Get-Item -Path 'Cert:\CurrentUser\My\ABCDEF1234567890' #i.e. this points to the certificate in my certificate store using the thumbprint of the SII certificate
$proxy = New-WebServiceProxy -Uri $uri
$proxy.ClientCertificates.Add($certificate)
$proxy.AllowAutoRedirect = $true
This works & shows the available operations, but gives no indication on how I'd select only the TEST (SuministroFactEmitidasPruebas
) port.
I thought you could specify a service's port through the
class
attribute:Otherwise, I think it chooses the first port, but don't quote me on that. Hope that helps.