我正在寻找一种简单的方法来构建一个SOAP请求,以便使用.NET Web服务,但是我发现几乎没有关于此主题的文档。默认的库javax.xml.soap在构造请求方面比模糊不清。从Java Soap客户端使用.NET Web服务?
是否有任何图书馆可以让我的生活更轻松?
我发现这段代码在某处,我现在不知道它是如何使用的或者它来自哪个库,但我非常想类似的东西,而不是使用DOM手动构建整个xml消息,或类似的东西(因为它需要SOAP的简单了)
SoapRequestBuilder s = new SoapRequestBuilder();
s.Server = "127.0.0.1"; // server ip address or name
s.MethodName = "ConcatWithSpace";
s.XmlNamespace = "http://tempuri.org/";
s.WebServicePath = "/SimpleService/Service1.asmx";
s.SoapAction = s.XmlNamespace+s.MethodName;
s.AddParameter("one", "David");
s.AddParameter("two", "Hobbs");
String response = s.sendRequest();
这是我要发送邮件形式:
POST /webservice/TimrService.asmx HTTP/1.1
Host: not.important.host
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetTimetableForBachelorYear"
<?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>
<GetTimetableForBachelorYear xmlns="http://tempuri.org/">
<year>I1</year>
<halfYear>A</halfYear>
</GetTimetableForBachelorYear>
</soap:Body>
</soap:Envelope>