Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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 SOAP java请求中的标头错误无效_Java_Web Services_Http_Soap - Fatal编程技术网

HTTP SOAP java请求中的标头错误无效

HTTP SOAP java请求中的标头错误无效,java,web-services,http,soap,Java,Web Services,Http,Soap,我正试图连接到这个Web服务()以通过Java程序绘制股票市场数据 他们在那个页面上有一个SOAP请求示例,我相信我在代码中复制的是正确的 这是我的密码: package stock; import java.net.*; import java.io.*; public class Stock { public static void main(String args[]) throws Exception { String XML = "<?xml versio

我正试图连接到这个Web服务()以通过Java程序绘制股票市场数据

他们在那个页面上有一个SOAP请求示例,我相信我在代码中复制的是正确的

这是我的密码:

    package stock;

import java.net.*;
import java.io.*;

public class Stock {

public static void main(String args[]) throws Exception {

    String XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
            + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
            + "  <soap:Body>"
            + "    <GetQuickQuote xmlns=\"http://ws.cdyne.com/\">"
            + "      <StockSymbol>GOOG</StockSymbol>"
            + "      <LicenseKey>0</LicenseKey>"
            + "    </GetQuickQuote>"
            + "  </soap:Body>"
            + "</soap:Envelope>";

    String hostname = "ws.cdyne.com";
    int port = 80;
    InetAddress addr = InetAddress.getByName(hostname);
    System.out.println(addr);
    Socket sock = new Socket(addr, port);

    //Send header
    String path = "/delayedstockquote/delayedstockquote.asmx";
    BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));
    // You can use "UTF8" for compatibility with the Microsoft virtual machine.
    wr.write("POST " + path + " HTTP/1.1\r\n");
    wr.write("Host: ws.cdyne.com\r\n");
    wr.write("Content-Type: text/xml; charset=utf-8\r\n");
    wr.write("Content-Length: " + XML.length() + "\r\n");
    wr.write("SOAPAction: \"http://ws.cdyne.com/GetQuickQuote\"");
    wr.write("\r\n");

    //Send data
    wr.write(XML);
    wr.flush();

    // Response
    BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
        System.out.println(line);
    }
    }
}

这是什么意思

好吧,我摆脱了糟糕的标题错误。问题是我的头和我发送的XML字符串之间没有空格。只需添加另一个“wr.write(“\r\n”);”即可解决此问题。然而,我得到的答复并没有给我任何有意义的数据。我刚刚得到一个HTTP/1.1200,好的,缓存控制:没有缓存,Pragma:没有缓存…不知道为什么它不返回数据!
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/xml; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By:  ASP.NET
Date: Fri, 07 Feb 2014 19:14:13 GMT
Content-Length: 372