0

我正在尝试向 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 消息?

谢谢

4

1 回答 1

0

第一个工作计划

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();

}

}

}
于 2012-12-03T10:09:40.187 回答