2016-07-26 1 views
0

soapui에서 일부 웹 서비스 호출이 있습니다. 모니터 호출로 만들 수 있도록 스크립트에 넣고 싶습니다. 무엇이 최선의 선택이 될지 확신하지 못합니다. 그 전화를하고 모니터로 항아리에 스크립트를 사용하여 PS 스크립트를 작성하는 생각. 더 좋은 제안이 있으면 조언을 구하십시오. 당신의 도움을 주셔서 감사합니다! - 샘헤더 쿠키가 필요한 powershell에서 SoapUi 요청을 만드는 방법은 무엇입니까?

+0

그것은 아니다 정말 당신이 묻는 것을 명확히하지만'Invoke-WebRequest'를 사용하여 웹 요청을 호출 할 수 있습니다. WCF (SoapUI를 사용하고 있기 때문에 WCF 서비스라고 가정)로 작업 할 수 있어야합니다. –

+0

실례가 있습니까? 이 cmdlet을 사용해 보았습니다. 작동하지 않았습니다. soapui에서 요청을하면 쿠키 헤더가 필요합니다. 단계를 수행하는 데 도움이되는 예제를 제공 할 수 있다면. 감사! –

답변

0

음,이 같은 SOAP 요청을 보낼 수 있습니다 : 당신이 쿠키를 추가해야하는 경우

$soap = @" 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
     <Geocode xmlns="http://dev.virtualearth.net/webservices/v1/geocode/contracts"> 
     <request xmlns:a="http://dev.virtualearth.net/webservices/v1/geocode" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
      <Credentials xmlns="http://dev.virtualearth.net/webservices/v1/common"> 
       <ApplicationId>ThisIsMySecret</ApplicationId> 
       <Token i:nil="true" /> 
      </Credentials> 
      <Culture xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" /> 
      <ExecutionOptions xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" /> 
      <UserProfile xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" /> 
      <a:Address xmlns:b="http://dev.virtualearth.net/webservices/v1/common"> 
       <b:AddressLine>1747 Reynolds St NW</b:AddressLine> 
       <b:AdminDistrict>TN</b:AdminDistrict> 
       <b:CountryRegion i:nil="true" /> 
       <b:District i:nil="true" /> 
       <b:FormattedAddress i:nil="true" /> 
       <b:Locality>Knoxville</b:Locality> 
       <b:PostalCode>37921</b:PostalCode> 
       <b:PostalTown i:nil="true" /> 
      </a:Address> 
      <a:Options i:nil="true" /> 
      <a:Query i:nil="true" /> 
     </request> 
     </Geocode> 
    </s:Body> 
</s:Envelope> 
"@ 

$headers = @{ 
    'Content-Type' = 'text/xml; charset=utf-8'; 
    'SOAPAction' = 'http://dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode' 
} 

Invoke-WebRequest ` 
    -Uri http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc ` 
    -Body $soap ` 
    -Method Post ` 
    -Headers $headers 

방금 ​​$headers에 문자열을 추가 할 수 있습니다

$headers = @{ 
    'Content-Type' = 'text/xml; charset=utf-8'; 
    'SOAPAction' = 'http://dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode'; 
    'Cookie' = 'YouCookieGoesHere' 
} 
+0

고마워요! 나는 이것을 시도하고이 오류가 발생했다 : + Invoke-WebRequest' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CategoryInfo : NotSpecified : (:) [Invoke-WebRequest], ArgumentException + FullyQualifiedErrorId : System.ArgumentException, Microsoft.PowerShell.Commands.InvokeWebRequestCommand –

+0

사용중인 PowerShell 버전은 무엇입니까? –

+0

PowerShell 버전 3.0 –

관련 문제