English 中文(简体)
利用Java Soap客户端的网络服务?
原标题:Consuming a .NET web service from a Java Soap Client?

我寻找一个简单的方法来构建肥皂请求,以便消费.NET网络服务,但我发现几乎没有关于这个主题的文件。默认的图书馆 javax.xml.soap 在如何构建该请求方面非常模糊。

是否有图书馆可以让我的生活更加轻松?

我找到这个代码的某处, 我现在不知道它是如何使用的, 或者它来自什么图书馆, 但我非常喜欢类似的东西, 而不是用 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>
最佳回答

http://docs.oracle.com/javaee/1.4/tumental/doc/SAAJ4.html" rel=“nofollow” >http://docs.oracle.com/javaee/1.4/tumental/doc/SAAJ4.html 一个很好的SAAJ例子。

问题回答

我本人是.NET开发者,但是我们有一个与Java开发者团队的第三党融合 消耗了我们的一项服务,我听到他们经常提到代号生成工具 wsdl2java 和一个名为 SOAPUI 的测试界面。我想这可能是这样的东西: >http://cxf.apache.org/docs/wsdl-to-java.html 。如果我理解正确的话,它有点像在.NET中添加一个网络服务参考,通过自动生成关注SOAP所有呼叫的班。你只需在参数中调用正确的方法和通过。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签