Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用http读取golang中的FederationMetadata.xml_Xml_Http_Go - Fatal编程技术网

使用http读取golang中的FederationMetadata.xml

使用http读取golang中的FederationMetadata.xml,xml,http,go,Xml,Http,Go,我试图通过以下方式在戈兰使用http获取FederationMetadata.xml response, err := client.Get("https://domainc.local/FederationMetadata/2007-06/FederationMetadata.xml"). 响应主体返回为所有数值(见下文),而不是XML格式。但是我可以从chrome下载这个xml文件 61 34 117 114 110 58 111 97 115 105 115 58 110 97 109

我试图通过以下方式在戈兰使用http获取FederationMetadata.xml

response, err := client.Get("https://domainc.local/FederationMetadata/2007-06/FederationMetadata.xml"). 
响应主体返回为所有数值(见下文),而不是XML格式。但是我可以从chrome下载这个xml文件

61 34 117 114 110 58 111 97 115 105 115 58 110 97 109 101 115 58
116 99 58 83 65 77 76 58 50 46 48 58 97 115 115 101 114 116 105 111
110 34 47 62 60 65 116 116 114 105 98 117 116 101 32 78 97 109 101
61 34 104 116 116 112 58 47 47 115 99 104 101 109 97 115 46 109
105 99 114 111 115 111 102 116 46 99 111 109 47 50 48 49 50 47 48
49 47 114 101 113 117 101 115 116 99 111 110 116 101 120 116 47 99 10
代码:


responseXML
是字节片(一个
[]字节

您必须将其转换为字符串才能打印,可以使用:

fmt.Println(string(responseXML))
或通过Printf格式字符串中的
%s

fmt.Printf("This is the response: \n%s\n", responseXML)
而不是
fmt.Println(response.Body)
使用
fmt.Println(string(response.Body))
,它应该打印:

... ="urn:oasis:names:tc:SAML:2.0:assertion"/><Attribute Name="http://schemas.microsoft.com/2012/01/requestcontext/c ...

=“urn:oasis:names:tc:SAML:2.0:assertion”/>请提供一个您正在做的示例。看起来您正在从响应的一部分打印一个
[]字节
。我正在打印response.body。这是我的代码:tr:=&http.Transport{TLSClientConfig:&tls.Config{insureskipverify:true},}client:=&http.client{Transport:tr}response,err:=client.Get(“)if err!=nil{os.Exit(1)}else{defer response.Body.Close()fmt.Println(response.Body)responseXML,err:=ioutil.ReadAll(response.Body)如果err!=nil{fmt.Printf(“%s”,err)os.Exit(1)}fmt.Println(responseXML)}尝试编辑问题并添加一些代码。在当前形式下,任何人都不可能确切知道您的问题是什么。请将您的代码放入问题并正确格式化。在注释中很难阅读(尤其是因为无法正确解析)。谢谢@AlexatNet编辑。
... ="urn:oasis:names:tc:SAML:2.0:assertion"/><Attribute Name="http://schemas.microsoft.com/2012/01/requestcontext/c ...