我可以运行“hello world”脚本,但是尝试运行这个sample脚本:
C:\Users\thufir\Desktop>
C:\Users\thufir\Desktop>powershell -ExecutionPolicy RemoteSigned
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> type .\stock.ps1
# Working example of how to use PowerShell (version >= 2) to access a web service.
$svc = New-WebServiceProxy –Uri ‘http://www.webservicex.net/stockquote.asmx?WSDL’
$svc | Get-Member # Use Get-Member to discover the interface of a web service.
# Get stock quotes.
$svc.GetQuote(‘BA’) # Boeing
$svc.GetQuote(‘AMZN’) # Amazon
$svc.GetQuote(‘SBUX’) # Starbucks
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\stock.ps1
TypeName: Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vicex_net_stockquote_a
smx_WSDL.StockQuote
Name MemberType Definition
---- ---------- ----------
Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs)
GetQuoteCompleted Event Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes....
Abort Method void Abort()
BeginGetQuote Method System.IAsyncResult BeginGetQuote(string symbol, System.AsyncCallbac...
CancelAsync Method void CancelAsync(System.Object userState)
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Discover Method void Discover()
Dispose Method void Dispose(), void IDisposable.Dispose()
EndGetQuote Method string EndGetQuote(System.IAsyncResult asyncResult)
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetQuote Method string GetQuote(string symbol)
GetQuoteAsync Method void GetQuoteAsync(string symbol), void GetQuoteAsync(string symbol,...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
ToString Method string ToString()
AllowAutoRedirect Property bool AllowAutoRedirect {get;set;}
ClientCertificates Property System.Security.Cryptography.X509Certificates.X509CertificateCollect...
ConnectionGroupName Property string ConnectionGroupName {get;set;}
Container Property System.ComponentModel.IContainer Container {get;}
CookieContainer Property System.Net.CookieContainer CookieContainer {get;set;}
Credentials Property System.Net.ICredentials Credentials {get;set;}
EnableDecompression Property bool EnableDecompression {get;set;}
PreAuthenticate Property bool PreAuthenticate {get;set;}
Proxy Property System.Net.IWebProxy Proxy {get;set;}
RequestEncoding Property System.Text.Encoding RequestEncoding {get;set;}
Site Property System.ComponentModel.ISite Site {get;set;}
SoapVersion Property System.Web.Services.Protocols.SoapProtocolVersion SoapVersion {get;s...
Timeout Property int Timeout {get;set;}
UnsafeAuthenticatedConnectionSharing Property bool UnsafeAuthenticatedConnectionSharing {get;set;}
Url Property string Url {get;set;}
UseDefaultCredentials Property bool UseDefaultCredentials {get;set;}
UserAgent Property string UserAgent {get;set;}
exception
exception
exception
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop>
这是政策问题吗?或者,脚本本身的问题?
也:
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\hello.ps1
hi
Cannot convert value "Data Not Found" to type "System.Xml.XmlDocument". Error: "The specified node cannot be inserted
as the valid child of this node, because the specified node is the wrong type."
At C:\Users\thufir\Desktop\hello.ps1:8 char:1
+ [xml]$response = $proxy.GetWeather("Tampa", "United States")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastToXmlDocument
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> type .\hello.ps1
echo "hi"
$proxy = New-WebServiceProxy -Uri http://www.webservicex.net/globalweather.asmx?WSDL
[xml]$response = $proxy.GetWeather("Tampa", "United States")
$response.CurrentWeather | Format-List
PS C:\Users\thufir\Desktop>
答案 0 :(得分:1)
在我看来,这是您正在调用的Web服务的问题。它返回字符串" exception"。您的代码运行正常。
导航到网站Stock Quote Detail并运行测试我也会在那里返回异常。
答案 1 :(得分:1)
尝试运行此操作并获得例外:
PS:14:27:35> $ quote = Invoke-RestMethod -Uri" http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=GOOGL" -Method Get
PS:14:27:49> $ quote.string
xmlns #text
----- -----
http://www.webserviceX.NET/例外
PS:14:27:53> $ quote.string'#文本'
。答案 2 :(得分:0)
#include<stdio.h>
#include<stdlib.h>
static char mem[4];
int main()
{
int* A = (int*)(mem);
mem[0] = 0;
mem[1] = 1;
mem[2] = 2;
mem[3] = 3;
int i;
A[0] = 5;
for (i = 0; i<4; i++)
{
printf("%d\t", mem[i]);
}
printf("\n");
return 0;
}
只是在黑暗中摸索着。但是,有趣的是:)