简体   繁体   English

使用Axis2向Java中的WSDL地址发出SOAP请求

[英]Making a SOAP Request to a WSDL address in Java, with Axis2

I am trying to send querys to a SOAP client. 我正在尝试将查询发送到SOAP客户端。

I have currently done the following: 我目前已执行以下操作:

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

When I run the JUnit tests 32/32 run, but 16 error. 我在运行JUnit测试时以32/32运行,但出现16错误。

What do I need to do now to send a SOAP Message to my server? 我现在需要做什么才能将SOAP消息发送到服务器? I have a sample SOAP Message provided by the service that I would like to send. 我有一个要发送的服务提供的示例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>

Do I have to worry about my JUnit tests failing. 我是否需要担心我的JUnit测试失败。 And what should I do to create and send the SOAP Message? 我应该怎么做才能创建和发送SOAP消息?

THanks 谢谢

First Working Program 第一个工作程序

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

}

}

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM