【发布时间】:2011-12-12 17:20:34
【问题描述】:
我在服务器上部署了一个 HelloWorld Web 服务。现在我试图与服务器交谈。如何从 Java 应用程序中执行 SOAP 请求?
这是 XML 信封(请求):
POST /AndroidSampleApp/Test.asmx HTTP/1.1
Host: (host)
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/HelloWorld"
<?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>
<HelloWorld xmlns="http://tempuri.org/">
<username>string</username>
<password>string</password>
</HelloWorld>
</soap:Body>
</soap:Envelope>
这是 XML 信封(请求):
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
我如何从 java 程序调用这个 web 服务以及我需要导入哪些包。谢谢!
注意:这是针对安卓应用的
【问题讨论】:
标签: java android web-services web-applications