【问题标题】:Making a SOAP Request to a WSDL address in Java, with Axis2使用 Axis2 向 Java 中的 WSDL 地址发出 SOAP 请求
【发布时间】:2012-12-03 08:27:59
【问题描述】:

我正在尝试向 SOAP 客户端发送查询。

我目前做了以下事情:

Configured Tomcat7 to run on my linux VMWare.
Installed Java, Eclipse, Axis2, and Axis2 plugins for Eclipse.
Run the Axis2 plugins and generated: ContentServiceCallbackHandler.java, ContentServiceFaultException.java, and ContentServiceStub.java

当我运行 JUnit 测试 32/32 运行,但 16 错误。

我现在需要做什么才能将 SOAP 消息发送到我的服务器?我有一个我想发送的服务提供的示例 SOAP 消息。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://content.tripadvisor.com" xmlns:api="http://api.content.tripadvisor.com">
   <soapenv:Header/>
   <soapenv:Body>
  <con:getPhotos>
     <con:in0>
        <api:clientLoginID>3CFC3B05146B40048B0C105A6CB9748F</api:clientLoginID>
        <api:domain>en</api:domain>
        <api:locationId>321151</api:locationId>
        <api:numPhotos>3</api:numPhotos>
        </con:in0>
      </con:getPhotos>
   </soapenv:Body>
</soapenv:Envelope>

我是否必须担心我的 JUnit 测试失败。我应该如何创建和发送 SOAP 消息?

谢谢

【问题讨论】:

    标签: java eclipse soap axis2 tomcat7


    【解决方案1】:

    第一个工作计划

    package com.tripadvisor.content.test;
    
    import java.rmi.RemoteException;
    
    import org.apache.axis2.AxisFault;
    
    import com.tripadvisor.content.ContentServiceFaultException;
    
    import com.tripadvisor.content.ContentServiceStub;
    
    import com.tripadvisor.content.ContentServiceStub.ArrayOfCdsPhoto;
    
    import com.tripadvisor.content.ContentServiceStub.CdsPhotoOptions;
    
    public class testClient {
    
    public static void main(String args[]){
    
    try {
    
    ContentServiceStub css = new ContentServiceStub();
    
    ContentServiceStub.GetPhotos getInc =  new ContentServiceStub.GetPhotos();
    
    ContentServiceStub.GetPhotosResponse resp = new ContentServiceStub.GetPhotosResponse();
    
    CdsPhotoOptions param = new CdsPhotoOptions();
    
    param.setClientLoginID(“3CFC3B05146B40048B0C105A6CB9748F”);
    
    param.setDomain(“en”);
    
    param.setLocationId(321151);
    
    param.setNumPhotos(3);
    
    getInc.setIn0(param);
    
    css._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
    
    try {
    
    resp = css.getPhotos(getInc);
    
    ArrayOfCdsPhoto photos = resp.getOut();
    
    System.out.println(“Complete”);
    
    } catch (RemoteException e) {
    
    // TODO Auto-generated catch block
    
    e.printStackTrace();
    
    } catch (ContentServiceFaultException e) {
    
    // TODO Auto-generated catch block
    
    e.printStackTrace();
    
    }
    
    } catch (AxisFault e) {
    
    // TODO Auto-generated catch block
    
    e.printStackTrace();
    
    }
    
    }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多