Web services 无法在Powershell中创建用于调用web服务的对象
这可能是个愚蠢的问题。如果是这样,请原谅我 我的目标是从powershell脚本调用用Java和Axis2开发的https web服务 下面是我创建的一个示例web服务,我甚至无法通过powershell调用它 Web服务方法实现Web services 无法在Powershell中创建用于调用web服务的对象,web-services,powershell,ssl-certificate,Web Services,Powershell,Ssl Certificate,这可能是个愚蠢的问题。如果是这样,请原谅我 我的目标是从powershell脚本调用用Java和Axis2开发的https web服务 下面是我创建的一个示例web服务,我甚至无法通过powershell调用它 Web服务方法实现 package com.webservice; public class AreaOperations { public Area calculateArea(Dimension dimension) { Area area = n
package com.webservice;
public class AreaOperations
{
public Area calculateArea(Dimension dimension)
{
Area area = new Area();
area.setArea(dimension.getLength() * dimension.getBreadth());
return area;
}
}
Soap请求
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://webservice.com" xmlns:xsd="http://webservice.com/xsd">
<soap:Header/>
<soap:Body>
<web:calculateArea>
<!--Optional:-->
<web:dimension>
<!--Optional:-->
<xsd:breadth>100</xsd:breadth>
<!--Optional:-->
<xsd:length>200</xsd:length>
</web:dimension>
</web:calculateArea>
</soap:Body>
</soap:Envelope>
$URI="http://localhost:8080/axis2/services/AreaOperations?wsdl"
$proxy=New-WebServiceProxy -uri $URI
#get autogenerated namespace
$type = $proxy.GetType().Namespace
#create the data type
$CalculateAreaRequestDT = ($type + '.calculateArea')
$DimensionDT = ($type + '.dimension')
#create objects
$areaRequest = new-object ($CalculateAreaRequestDT)
$dimension = new-object ($DimensionDT)
# Assign values
$dimension.length="200"
$dimension.width="100"
$areaRequest.dimension=$dimension
#Tada
$proxy.authenticateUser($areaRequest)
但是,当我执行行$areaRequest=new object($calculateareRequestdt)
新对象:找不到类型[Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy 12_Area Operations_wsdl.calculateArea]:确保加载了包含此类型的程序集。
第1行字符:26
+$areaRequest=new object如果执行$proxy.calculateArea(100.0200.0)
?@KeithHill感谢您的回复。当我给出命令$proxy | gm
时,我得到以下作为方法签名:System.Void calculateArea(浮点长度,指定布尔长度,浮点宽度,指定布尔宽度,System.Double&,mscorlib,版本=2.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089返回,System.Boolean&,mscorlib,版本=2.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089返回指定)
。我不知道如何调用此方法。因此,我将更改我的方法签名并再次发布查询,任何回复都将非常有用
New-Object : Cannot find type [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy12_services_AreaOperations_wsdl.calculateArea]: make sure the assembly containing this type is loaded.
At line:1 char:26
+ $areaRequest = new-object <<<< ($CalculateAreaRequestDT)
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand