简体   繁体   中英

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

I am trying to send querys to a SOAP client.

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.

What do I need to do now to send a SOAP Message to my server? I have a sample SOAP Message provided by the service that I would like to send.

<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. And what should I do to create and send the SOAP Message?

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

}

}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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