package demo.test;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.tempuri.ReservationService;
import org.tempuri.ReservationServiceSoap;
import com.micros.webservices.og._4_3.common.Text;
import com.micros.webservices.og._4_3.common.UniqueID;
import com.micros.webservices.og._4_3.common.UniqueIDType;
import com.micros.webservices.og._4_3.core.EndPoint;
import com.micros.webservices.og._4_3.core.OGHeader;
import com.micros.webservices.og._4_3.hotelcommon.CancelTerm;
import com.micros.webservices.og._4_3.hotelcommon.CancelTermType;
import com.micros.webservices.og._4_3.hotelcommon.GDSResultStatus;
import com.micros.webservices.og._4_3.hotelcommon.HotelReference;
import com.micros.webservices.og._4_3.hotelcommon.Paragraph;
import com.micros.webservices.ows._5_1.reservation.CancelBookingRequest;
import com.micros.webservices.ows._5_1.reservation.CancelBookingResponse;
public class Demo1 {
public static void main(String[] args) {
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
ReservationService service = new ReservationService();
ReservationServiceSoap soap = service.getReservationServiceSoap();
CancelBookingRequest cancelBookingRequest = new CancelBookingRequest();
HotelReference ref = new HotelReference();
ref.setChainCode("ChainCodeXX");
ref.setHotelCode("HotelCodeXX");
cancelBookingRequest.setHotelReference(ref);
UniqueID num = new UniqueID();
num.setValue("220804");
num.setType(UniqueIDType.INTERNAL);
cancelBookingRequest.setConfirmationNumber(num);
cancelBookingRequest.setLastName("ZHANG SANSI");
CancelTerm cancel = new CancelTerm();
cancel.setCancelType(CancelTermType.CANCEL);
cancel.setCancelReasonCode("Cancel");
Paragraph pa = new Paragraph();
Text txt = new Text();
txt.setValue("測試取消");
JAXBElement<Text> t = new JAXBElement<Text>(new QName(
"http://webservices.micros.com/og/4.3/HotelCommon/", "Text"),
Text.class, txt);
pa.getURLOrTextOrImage().add(t);
cancelBookingRequest.setCancelTerm(cancel);
OGHeader header = new OGHeader();
header.setTransactionID("000032");
EndPoint orgin = new EndPoint();
orgin.setEntityID("ChannelCodeXX");
orgin.setSystemType("WEB");
header.setOrigin(orgin);
EndPoint des = new EndPoint();
des.setEntityID("ORS");
des.setSystemType("ORS");
header.setDestination(des);
CancelBookingResponse res = soap.cancelBooking(header,
cancelBookingRequest);
GDSResultStatus status = res.getResult();
System.out.println(status.getResultStatusFlag());
System.out.print("-------------");
System.out.println(status.getGDSError().getValue());
}
}
View Code
package org.tempuri;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import cn.net.chinaonline.webservices._switch._1_5_1.reservation.CreateBookingRequest;
import cn.net.chinaonline.webservices._switch._1_5_1.reservation.ModifyBookingRequest;
import com.micros.webservices.og._4_3.core.OGHeader;
import com.micros.webservices.ows._5_1.reservation.CancelBookingRequest;
import com.micros.webservices.ows._5_1.reservation.CancelBookingResponse;
import com.micros.webservices.ows._5_1.reservation.CreateBookingResponse;
import com.micros.webservices.ows._5_1.reservation.FetchBookingStatusRequest;
import com.micros.webservices.ows._5_1.reservation.FetchBookingStatusResponse;
import com.micros.webservices.ows._5_1.reservation.ModifyBookingResponse;
/**
* This class was generated by the JAX-WS RI. JAX-WS RI 2.1.6 in JDK 6 Generated
* source version: 2.1
*
*/
@WebService(name = "ReservationServiceSoap", targetNamespace = "http://tempuri.org/")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
com.micros.webservices.og._4_3.name.ObjectFactory.class,
cn.net.chinaonline.webservices._switch._1_5_1.reservation.ObjectFactory.class,
com.micros.webservices.og._4_3.membership.ObjectFactory.class,
com.micros.webservices.ows._5_1.reservation.ObjectFactory.class,
com.micros.webservices.og._4_3.common.ObjectFactory.class,
com.micros.webservices.og._4_3.core.ObjectFactory.class,
com.micros.webservices.og._4_3.reservation.ObjectFactory.class,
com.micros.webservices.og._4_3.hotelcommon.ObjectFactory.class,
com.micros.webservices.og._4_3.activity.ObjectFactory.class })
public interface ReservationServiceSoap {
/**
*
* @param fetchBookingStatusRequest
* @return returns
* com.micros.webservices.ows._5_1.reservation.FetchBookingStatusResponse
*/
@WebMethod(operationName = "FetchBookingStatus", action = "http://webservices.micros.com/ows/5.1/Reservation.wsdl#FetchBookingStatus")
@WebResult(name = "FetchBookingStatusResponse", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "FetchBookingStatusResult")
public FetchBookingStatusResponse fetchBookingStatus(
@WebParam(name = "FetchBookingStatusRequest", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "FetchBookingStatusRequest") FetchBookingStatusRequest fetchBookingStatusRequest);
/**
*
* @param createBookingRequest
* @return returns
* com.micros.webservices.ows._5_1.reservation.CreateBookingResponse
*/
@WebMethod(operationName = "CreateBooking", action = "http://webservices.micros.com/ows/5.1/Reservation.wsdl#CreateBooking")
@WebResult(name = "CreateBookingResponse", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "CreateBookingResult")
public CreateBookingResponse createBooking(
@WebParam(name = "CreateBookingRequest", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "CreateBookingRequest") CreateBookingRequest createBookingRequest);
/**
*
* @param modifyBookingRequest
* @return returns
* com.micros.webservices.ows._5_1.reservation.ModifyBookingResponse
*/
@WebMethod(operationName = "ModifyBooking", action = "http://webservices.micros.com/ows/5.1/Reservation.wsdl#ModifyBooking")
@WebResult(name = "ModifyBookingResponse", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "ModifyBookingResult")
public ModifyBookingResponse modifyBooking(
@WebParam(name = "ModifyBookingRequest", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "ModifyBookingRequest") ModifyBookingRequest modifyBookingRequest);
/**
*
* @param cancelBookingRequest
* @return returns
* com.micros.webservices.ows._5_1.reservation.CancelBookingResponse
*/
@WebMethod(operationName = "CancelBooking", action = "http://webservices.micros.com/ows/5.1/Reservation.wsdl#CancelBooking")
@WebResult(name = "CancelBookingResponse", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "CancelBookingResult")
public CancelBookingResponse cancelBooking(
@WebParam(name = "OGHeader", targetNamespace = "http://webservices.micros.com/og/4.3/Core/", partName = "OGHeader") OGHeader header,
@WebParam(name = "CancelBookingRequest", targetNamespace = "http://webservices.micros.com/ows/5.1/Reservation.wsdl", partName = "CancelBookingRequest") CancelBookingRequest cancelBookingRequest);
}
View Code
@WebParam(name = "OGHeader", targetNamespace = "http://webservices.micros.com/og/4.3/Core/", partName = "OGHeader") OGHeader header,
這一段代碼是要另外加的。