Powershell调用webrequest-POST(webservice)
我试图将此SOAP发布到我们的web服务中,它返回信息,但我希望它创建一个票证。老实说,我对这一点完全陌生,我已经尝试了一切,谷歌搜索了一切,任何想法都会很棒。我正在使用powershell 3.0 这是肥皂Powershell调用webrequest-POST(webservice),powershell,soap,Powershell,Soap,我试图将此SOAP发布到我们的web服务中,它返回信息,但我希望它创建一个票证。老实说,我对这一点完全陌生,我已经尝试了一切,谷歌搜索了一切,任何想法都会很棒。我正在使用powershell 3.0 这是肥皂 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:HPD_IncidentInterface_Create_WS">
<soap:Header>
<s0:AuthenticationInfo>
<s0:userName>******</s0:userName>
<s0:password>******</s0:password>
<s0:authentication/>
</s0:AuthenticationInfo>
</soap:Header>
<soap:Body>
<s0:HelpDesk_Submit_Service>
<s0:Assigned_Group>TTG Service Desk</s0:Assigned_Group>
<s0:Assigned_Support_Company>********* Services</s0:Assigned_Support_Company>
<s0:Assigned_Support_Organization>ICT and IS</s0:Assigned_Support_Organization>
<s0:Assignee>*********</s0:Assignee>
<s0:Categorization_Tier_1>Unlock</s0:Categorization_Tier_1>
<s0:Categorization_Tier_2>Account</s0:Categorization_Tier_2>
<s0:Categorization_Tier_3>Access Denied</s0:Categorization_Tier_3>
<s0:First_Name>Inbound</s0:First_Name>
<s0:Impact>4-Minor/Localized</s0:Impact>
<s0:Last_Name>Email</s0:Last_Name>
<s0:Product_Categorization_Tier_1>Software</s0:Product_Categorization_Tier_1>
<s0:Product_Categorization_Tier_2>Software Application/System</s0:Product_Categorization_Tier_2>
<s0:Product_Categorization_Tier_3>Application Platform</s0:Product_Categorization_Tier_3>
<s0:Product_Name>Active Directory - OPAL</s0:Product_Name>
<s0:Reported_Source>Direct Input</s0:Reported_Source>
<s0:Resolution>Password reset</s0:Resolution>
<s0:Service_Type>User Service Request</s0:Service_Type>
<s0:Status>Resolved</s0:Status>
<s0:Action>CREATE</s0:Action>
<s0:Summary>Password Reset - OPAL</s0:Summary>
<s0:Notes>Password Reset - OPAL</s0:Notes>
<s0:Urgency>4-Low</s0:Urgency>
<s0:Status_Reason>No Further Action Required</s0:Status_Reason>
</s0:HelpDesk_Submit_Service>
</soap:Body>
</soap:Envelope>
xml文件包含顶部的第一个代码。。。。对不起,如果我没有提供正确的信息或错过了一些重要的。我最初试图通过VBA实现这一点,因为这是我的代码在outlook中作为宏产生的地方
无论如何,AnyOne的帮助将是惊人的。函数执行GetDocumentList
function Execute-GetDocumentList
(
[Xml] $SOAPRequest,
[String] $URL
)
{
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction",
"`"/.././listDocuments`"") ("Find end point")
$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Method = "POST"
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
$responseStream.Close()
write-host "Response Received."
return $ReturnXml
}
$soap = [xml]@"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HPD_IncidentInterface_Create_WS">
<soap:Header>
<s0:AuthenticationInfo>
<s0:userName>******</s0:userName>
<s0:password>******</s0:password>
<s0:authentication/>
</s0:AuthenticationInfo>
</soap:Header>
<soap:Body>
<s0:HelpDesk_Submit_Service>
<s0:Assigned_Group>TTG Service Desk</s0:Assigned_Group>
<s0:Assigned_Support_Company>********* Services</s0:Assigned_Support_Company>
<s0:Assigned_Support_Organization>ICT and IS</s0:Assigned_Support_Organization>
<s0:Assignee>*********</s0:Assignee>
<s0:Categorization_Tier_1>Unlock</s0:Categorization_Tier_1>
<s0:Categorization_Tier_2>Account</s0:Categorization_Tier_2>
<s0:Categorization_Tier_3>Access Denied</s0:Categorization_Tier_3>
<s0:First_Name>Inbound</s0:First_Name>
<s0:Impact>4-Minor/Localized</s0:Impact>
<s0:Last_Name>Email</s0:Last_Name>
<s0:Product_Categorization_Tier_1>Software</s0:Product_Categorization_Tier_1>
<s0:Product_Categorization_Tier_2>Software
Application/System</s0:Product_Categorization_Tier_2>
<s0:Product_Categorization_Tier_3>Application
Platform</s0:Product_Categorization_Tier_3>
<s0:Product_Name>Active Directory - OPAL</s0:Product_Name>
<s0:Reported_Source>Direct Input</s0:Reported_Source>
<s0:Resolution>Password reset</s0:Resolution>
<s0:Service_Type>User Service Request</s0:Service_Type>
<s0:Status>Resolved</s0:Status>
<s0:Action>CREATE</s0:Action>
<s0:Summary>Password Reset - OPAL</s0:Summary>
<s0:Notes>Password Reset - OPAL</s0:Notes>
<s0:Urgency>4-Low</s0:Urgency>
<s0:Status_Reason>No Further Action Required</s0:Status_Reason>
</s0:HelpDesk_Submit_Service>
</soap:Body>
</soap:Envelope>
"@
$ret = Execute-GetDocumentList $soap
"https://u/...../Service?
WSDL"
#$Token_ListDocument = $ret.Envelope.Header.Authentication.SecurityToken
$s=$ret.Envelope.Body.InnerXml | ft
$s
#or
$document = $xmls.DocumentElement.ChildNodes
(
[Xml]$SOAPRequest,
[字符串]$URL
)
{
写入主机“向服务器发送SOAP请求:$URL”
$soapWebRequest=[System.Net.WebRequest]::创建($URL)
$soapWebRequest.Headers.Add(“SOAPAction”,
“`/..//listDocuments`”(“查找终点”)
$soapWebRequest.ContentType=“text/xml;字符集=`“utf-8`”
$soapWebRequest.Method=“POST”
写入主机“启动发送”
$requestStream=$soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()
写入主机“发送完成,等待响应”
$resp=$soapWebRequest.GetResponse()
$responseStream=$resp.GetResponseStream()
$soapReader=[System.IO.StreamReader]($responseStream)
$ReturnXml=[Xml]$soapReader.ReadToEnd()
$responseStream.Close()
写入主机“收到响应”
return$ReturnXml
}
$soap=[xml]@”
******
******
TTG服务台
*********服务
信息和通信技术与信息系统
*********
解锁
账户
拒绝访问
入境
4-小调/本地化
电子邮件
软件
软件
应用程序/系统
应用
站台
Active Directory-蛋白石
直接输入
密码重置
用户服务请求
断然的
创造
密码重置-蛋白石
密码重置-蛋白石
4-低
无需采取进一步行动
"@
$ret=执行GetDocumentList$soap
"https://u/...../Service?
WSDL“
#$Token_ListDocument=$ret.Envelope.Header.Authentication.SecurityToken
$s=$ret.Envelope.Body.InnerXml | ft
$s
#或
$document=$xmls.DocumentElement.ChildNodes
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns0:HelpDesk_Submit_ServiceResponse xmlns:ns0="urn:HPD_IncidentInterface_Create_WS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Incident_Number>INC000000572219</ns0:Incident_Number>
</ns0:HelpDesk_Submit_ServiceResponse>
</soapenv:Body>
</soapenv:Envelope>
Invoke-WebRequest http://rem-dev05/arsys/WSDL/public/rem-dev05/HPD_IncidentInterface_Create_WS -method POST -InFile C:\Passwords\Logs\ticket.xml
function Execute-GetDocumentList
(
[Xml] $SOAPRequest,
[String] $URL
)
{
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction",
"`"/.././listDocuments`"") ("Find end point")
$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Method = "POST"
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
$responseStream.Close()
write-host "Response Received."
return $ReturnXml
}
$soap = [xml]@"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HPD_IncidentInterface_Create_WS">
<soap:Header>
<s0:AuthenticationInfo>
<s0:userName>******</s0:userName>
<s0:password>******</s0:password>
<s0:authentication/>
</s0:AuthenticationInfo>
</soap:Header>
<soap:Body>
<s0:HelpDesk_Submit_Service>
<s0:Assigned_Group>TTG Service Desk</s0:Assigned_Group>
<s0:Assigned_Support_Company>********* Services</s0:Assigned_Support_Company>
<s0:Assigned_Support_Organization>ICT and IS</s0:Assigned_Support_Organization>
<s0:Assignee>*********</s0:Assignee>
<s0:Categorization_Tier_1>Unlock</s0:Categorization_Tier_1>
<s0:Categorization_Tier_2>Account</s0:Categorization_Tier_2>
<s0:Categorization_Tier_3>Access Denied</s0:Categorization_Tier_3>
<s0:First_Name>Inbound</s0:First_Name>
<s0:Impact>4-Minor/Localized</s0:Impact>
<s0:Last_Name>Email</s0:Last_Name>
<s0:Product_Categorization_Tier_1>Software</s0:Product_Categorization_Tier_1>
<s0:Product_Categorization_Tier_2>Software
Application/System</s0:Product_Categorization_Tier_2>
<s0:Product_Categorization_Tier_3>Application
Platform</s0:Product_Categorization_Tier_3>
<s0:Product_Name>Active Directory - OPAL</s0:Product_Name>
<s0:Reported_Source>Direct Input</s0:Reported_Source>
<s0:Resolution>Password reset</s0:Resolution>
<s0:Service_Type>User Service Request</s0:Service_Type>
<s0:Status>Resolved</s0:Status>
<s0:Action>CREATE</s0:Action>
<s0:Summary>Password Reset - OPAL</s0:Summary>
<s0:Notes>Password Reset - OPAL</s0:Notes>
<s0:Urgency>4-Low</s0:Urgency>
<s0:Status_Reason>No Further Action Required</s0:Status_Reason>
</s0:HelpDesk_Submit_Service>
</soap:Body>
</soap:Envelope>
"@
$ret = Execute-GetDocumentList $soap
"https://u/...../Service?
WSDL"
#$Token_ListDocument = $ret.Envelope.Header.Authentication.SecurityToken
$s=$ret.Envelope.Body.InnerXml | ft
$s
#or
$document = $xmls.DocumentElement.ChildNodes