使用CXF,注解,一个简单的webservice例子

一、服务

1.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">

	<display-name>eoswms</display-name>
	<!-- Start Spring Configuration // -->
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>eoswms</param-value>
	</context-param>
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>WEB-INF/classes/log4j.xml</param-value>
	</context-param>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:entity-spring.xml,classpath:services-spring.xml,classpath:schedule-spring.xml,classpath:cxf.xml</param-value>
	</context-param>
	<!-- The context params that read by ContextLoaderListener -->





	<!-- This listener will load other application context file in addition 
		to springweb-servlet.xml -->
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>



	<servlet>
		<servlet-name>rest</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>rest</servlet-name>
		<url-pattern>/service/*</url-pattern>
	</servlet-mapping>
	
    <!-- Start WebService -->
    <servlet>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/webservice/*</url-pattern>
    </servlet-mapping>
    <!-- End WebService -->


</web-app>

 

2.cxf.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="http://www.springframework.org/schema/beans  
       		http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
            http://cxf.apache.org/jaxws   
            http://cxf.apache.org/schemas/jaxws.xsd">
    <jaxws:endpoint id="orderWebService" implementor="com.eos.wms.webservice.OrderWebServiceImpl" address="/OrderWebService" />
</beans>

 3.OrderWebServiceImpl

package com.eos.wms.webservice;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Logger;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Resource;
import javax.jws.WebService;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.stereotype.Service;

import com.eos.wms.dao.IOrderDao;
import com.goms3.hibernate.HybrisItemRebate;
import com.goms3.hibernate.HybrisMemberPointAccount;
import com.goms3.hibernate.HysbrisCoupon;
import com.goms3.hibernate.OmsOrder;
import com.goms3.hibernate.OmsOrderItem;
import com.goms3.hibernate.OmsOrderPromo;

@WebService(endpointInterface = "com.eos.wms.webservice.OrderWebService",serviceName="OrderWebService",targetNamespace = "http://interfaces.cxf.com/")
@Service("orderService")
public class OrderWebServiceImpl implements OrderWebService {

	@Resource(name = "orderDao")
	private IOrderDao orderDao;
	
	public OrderWebServiceImpl(){
		
	}
	
	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
	
    private static final Logger LOG = Logger.getLogger(OrderWebServiceImpl.class.getName());

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#searchReturnByMemberId(java.lang.String  orderMemberId )*
     */
    public java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> searchReturnByMemberId(java.lang.String orderMemberId) { 
        LOG.info("Executing operation searchReturnByMemberId");
        System.out.println(orderMemberId);
        try {
            java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#syncCoupon(com.eos.wms.webservice.HybrisCouponBean  arg0 )*
     */
    public com.eos.wms.webservice.ResponseBean syncCoupon(com.eos.wms.webservice.HybrisCouponBean arg0) { 
        LOG.info("Executing operation syncCoupon");
        System.out.println(arg0);
        try {
            com.eos.wms.webservice.ResponseBean _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#searchOrderStats(java.lang.String  hybrisOrderNo )*
     */
    public java.lang.String searchOrderStats(java.lang.String hybrisOrderNo) { 
        LOG.info("Executing operation searchOrderStats");
        System.out.println(hybrisOrderNo);
        try {
            java.lang.String _return = "";
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }
    
	public String updateOrderStats(String orderCode, String status,
			String shippDescription) {
    	 LOG.info("Executing operation updateOrderStats");
         System.out.println("orderCode:" + orderCode + "; status:" + status + "; shippDescription:" + shippDescription);
         
         try {
        	 modfiyOrderStatus(orderCode, status, shippDescription);
             return "success";
         } catch (java.lang.Exception ex) {
             ex.printStackTrace();
             throw new RuntimeException(ex);
         }
	}
	

    /* 
     * @see com.eos.wms.webservice.OrderWebService#searchOrder(java.lang.String  hybrisOrderNo )*
     * 
     */
    public OmsOrderForHybris searchOrder(String hybrisOrderNo) { 
        LOG.info("Executing operation searchOrder");
        System.out.println(hybrisOrderNo);
        
        try {
            OmsOrderForHybris _return = null;
            OmsOrder omsOrder = orderDao.searchOrder(hybrisOrderNo);
            
            if (null != omsOrder) {
            	_return = new OmsOrderForHybris();
            	
            	_return.setSourceOrderNo(omsOrder.getSourceOrderNo());
            	_return.setOmsOrderNo(omsOrder.getOmsOrderNo());
            	_return.setOrderInternalStatus(omsOrder.getOrderInternalStatus());
            	_return.setShippingMethod(omsOrder.getShippingMethod());
            	_return.setShippingNo(omsOrder.getShippingNo());
            	
            	if (null != omsOrder.getShippingTime()) {
            		_return.setShippingTime(DateFormat.getDateInstance(DateFormat.DEFAULT).format(omsOrder.getShippingTime()));
            	}
            	
            	/* set OmsOrderItem Info */
            	Set  omsOrderItems = omsOrder.getOmsOrderItems();
            	Iterator it = omsOrderItems.iterator(); 
            	List<OmsOrderItemForHybris> itemList = new ArrayList<OmsOrderItemForHybris>();
            	OmsOrderItemForHybris itemBean = null;
            	OmsOrderItem itemEntity = null;
				while (it.hasNext()) {
					itemEntity = (OmsOrderItem)it.next();
					
					itemBean = new OmsOrderItemForHybris();
					if (null != itemEntity.getItemPrice()) {
						itemBean.setItemPrice(itemEntity.getItemPrice().doubleValue());
					}
	            	if (null != itemEntity.getItemQuantity()) {
	            		itemBean.setItemQuantity(Integer.valueOf(itemEntity.getItemQuantity().toString()));
	            	}
	            	if (null != itemEntity.getItemSku()) {
	            		itemBean.setItemSku(itemEntity.getItemSku());
	            	}
	            	if (null != itemEntity.getApportionAmount()) {
	            		itemBean.setApportionAmount(itemEntity.getApportionAmount().doubleValue());
	            	}
	            	
	            	itemList.add(itemBean);
				}
            	
            	_return.omsOrderItemForHybrises = itemList;
            }
            
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
        
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#searchReturnByReturnNo(java.lang.String  omsOrderReturnNo )*
     */
    public com.eos.wms.webservice.HybrisOrderReturnBean searchReturnByReturnNo(java.lang.String omsOrderReturnNo) { 
        LOG.info("Executing operation searchReturnByReturnNo");
        System.out.println(omsOrderReturnNo);
        try {
            com.eos.wms.webservice.HybrisOrderReturnBean _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#syncOrder(com.eos.wms.webservice.HybrisOrderNewBean  arg0 ,)com.eos.wms.webservice.UserInfoBean  arg1 )*
     */
    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#syncOrder(com.eos.wms.webservice.HybrisOrderNewBean, com.eos.wms.webservice.UserInfoBean)
     */
    public com.eos.wms.webservice.ResponseBean syncOrder(com.eos.wms.webservice.HybrisOrderNewBean arg0,com.eos.wms.webservice.UserInfoBean arg1) { 
    	LOG.info("Executing operation syncOrder");
    	
    	com.eos.wms.webservice.ResponseBean _return = new ResponseBean();
    	
    	//params from hybris , convert to model OmsOrder
    	OmsOrder omsOrder = new OmsOrder();
    	omsOrder.setWatsonsMemberId(arg0.getWatsonsMemberId());
    	omsOrder.setOmsOrderConsumer(arg0.getOmsOrderConsumer());
    	
    	String hybrisOrderNo = arg0.getHybrisOrderNo();
    	if(null == hybrisOrderNo || "".equals(hybrisOrderNo.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("hybrisOrderNo必填项不能为空");
            return _return;
    	}
    	omsOrder.setSourceOrderNo(hybrisOrderNo);
    	omsOrder.setWatsonsOrderNo(hybrisOrderNo);
    	
    	String paymentTime = arg0.getPaymentTime();
    	if(null == paymentTime || "".equals(paymentTime.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("paymentTime必填项不能为空");
            return _return;
    	}
    	
    	String orderTime = arg0.getOrderTime();
    	if(null == orderTime || "".equals(orderTime.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("orderTime必填项不能为空");
            return _return;
    	}
    	
    	try {
			omsOrder.setPaymentTime(format.parse(paymentTime));
			omsOrder.setOrderTime(format.parse(orderTime));
		} catch (ParseException e) {
			_return.setResultCode("5003");
            _return.setResutlDesc("paymentTime/orderTime数据类型或长度错误");
			e.printStackTrace();
			return _return;
		}
    	
    	String alipayPrice = arg0.getAlipayPrice();
    	if(null == alipayPrice || "".equals(alipayPrice.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("alipayPrice必填项不能为空");
            return _return;
    	}
    	omsOrder.setPaymentAlipayPrice(new BigDecimal(alipayPrice));
    	
    	String paymentAlipayNo = arg0.getPaymentAlipayNo();
    	if(null == paymentAlipayNo || "".equals(paymentAlipayNo.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("paymentAlipayNo必填项不能为空");
            return _return;
    	}
    	omsOrder.setPaymentAlipayNo(paymentAlipayNo);
    	
    	omsOrder.setPaymentAlipayTranscation(arg0.getPaymentTransactionId());
    	
    	String shippingMethod = arg0.getShippingMethod();
    	if(null == shippingMethod || "".equals(shippingMethod.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("shippingMethod必填项不能为空");
            return _return;
    	}
    	omsOrder.setShippingMethod(shippingMethod);
    	
    	String shippingTotal = arg0.getShippingTotal();
    	if(null == shippingTotal || "".equals(shippingTotal.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("shippingTotal必填项不能为空");
            return _return;
    	}
    	omsOrder.setShippingTotal(new BigDecimal(shippingTotal));
    	
    	omsOrder.setDeliveryDuring(arg0.getDeliveryDuring());
    	omsOrder.setInvoiceTitle(arg0.getInvoiceTitle());
    	omsOrder.setOrderComment(arg0.getOrderComment());
    	
    	String payedAmount = arg0.getPayedAmount();
    	if(null == payedAmount || "".equals(payedAmount.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("payedAmount必填项不能为空");
            return _return;
    	}
    	omsOrder.setPayedAmount(new BigDecimal(payedAmount));
    	
    	String needInvoice = arg0.getNeedInvoice();
    	if(null == needInvoice || "".equals(needInvoice.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("needInvoice必填项不能为空");
            return _return;
    	}
    	omsOrder.setIsNeedInvoice(needInvoice.charAt(0));
    	
    	String omsAddressProvince = arg0.getOmsAddressProvince();
    	if(null == omsAddressProvince || "".equals(omsAddressProvince.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsAddressProvince必填项不能为空");
            return _return;
    	}
    	omsOrder.setOmsAddressProvince(omsAddressProvince);
    	
    	String omsAddressCity = arg0.getOmsAddressCity();
    	if(null == omsAddressCity || "".equals(omsAddressCity.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsAddressCity必填项不能为空");
            return _return;
    	}
    	omsOrder.setOmsAddressCity(omsAddressCity);
    	
    	String omsAddressRegion = arg0.getOmsAddressRegion();
    	if(null == omsAddressRegion || "".equals(omsAddressRegion.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsAddressRegion必填项不能为空");
            return _return;
    	}
    	omsOrder.setOmsAddressRegion(omsAddressRegion);
    	
    	String omsOrderAddress = arg0.getOmsOrderAddress();
    	if(null == omsOrderAddress || "".equals(omsOrderAddress.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsOrderAddress必填项不能为空");
            return _return;
    	}
    	omsOrder.setOmsOrderAddress(omsOrderAddress);
    	
    	String omsOrderZip = arg0.getOmsOrderZip();
    	if(null == omsOrderZip || "".equals(omsOrderZip.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsOrderZip必填项不能为空");
            return _return;
    	}
    	omsOrder.setOmsOrderZip(omsOrderZip);
    	
    	String omsOrderMobile = arg0.getOmsOrderMobile();
    	String omsOrderPhone = arg0.getOmsOrderPhone();
    	if((null == omsOrderMobile || "".equals(omsOrderMobile.trim())) && 
    			(null == omsOrderPhone || "".equals(omsOrderPhone.trim()))) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("omsOrderMobile/omsOrderPhone必填项不能为空");
            return _return;
    	}	
    	omsOrder.setOmsOrderMobile(omsOrderMobile);
    	omsOrder.setOmsOrderPhone(omsOrderPhone);
    	
    	omsOrder.setOmsOrderEmail(arg0.getOmsOrderEmail());
    	omsOrder.setPaymentCoupon(arg0.getPaymentCoupon());
    	
    	String paymentCouponPrice = arg0.getPaymentCouponPrice();
    	if(null != paymentCouponPrice && !"".equals(paymentCouponPrice.trim())) {
    		omsOrder.setPaymentCouponPrice(new BigDecimal(paymentCouponPrice));
    	}
    	
    	omsOrder.setCouponType(arg0.getCouponType());
    	
    	String paymentMethod = arg0.getPaymentMethod();
    	if(null == paymentMethod || "".equals(paymentMethod.trim())) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("paymentMethod必填项不能为空");
            return _return;
    	}
    	omsOrder.setPaymentMethod(paymentMethod);
    	
    	omsOrder.setCouponPayRemark(arg0.getCouponPayRemark());
    	
    	List<HybrisOrderItemNewBean> hybrisOrderItemBeans = arg0.getHybrisOrderItemBeans();
    	if(null == hybrisOrderItemBeans || hybrisOrderItemBeans.size() == 0) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("hybrisOrderItemBeans必填项不能为空");
            return _return;
    	}
    	List<OmsOrderItem> omsOrderItemList = new ArrayList<OmsOrderItem>();
    	for (HybrisOrderItemNewBean itemBean : hybrisOrderItemBeans) {
    		OmsOrderItem omsOrderItem = new OmsOrderItem();
    		
    		String itemSku = itemBean.getItemSku();
    		if(null == itemSku || "".equals(itemSku.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemSku必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setItemSku(itemSku);
    		
    		String itemName = itemBean.getItemName();
    		if(null == itemName || "".equals(itemName.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemName必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setItemName(itemName);
    		
    		String itemType = itemBean.getItemType();
    		if(null == itemType || "".equals(itemType.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemType必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setItemType(itemType);
    		
    		String itemWeight = itemBean.getItemWeight();
//    		if(null == itemWeight || "".equals(itemWeight.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("itemWeight必填项不能为空");
//                return _return;
//        	}	
    		omsOrderItem.setItemWeight(new BigDecimal(itemWeight));
    		
    		omsOrderItem.setItemStandard(itemBean.getItemStandard());
    		
    		String itemDescription = itemBean.getItemDescription();
//    		if(null == itemDescription || "".equals(itemDescription.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("itemDescription必填项不能为空");
//                return _return;
//        	}	
    		omsOrderItem.setItemDescription(itemDescription);
    		
    		omsOrderItem.setItemComment(itemBean.getItemComment());
    		
    		String isFreeTax = itemBean.getFreeTax();
//    		if(null == isFreeTax || "".equals(isFreeTax.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("isFreeTax必填项不能为空");
//                return _return;
//        	}	
    		omsOrderItem.setIsFreeTax(isFreeTax);
    		
    		String itemQuantity = itemBean.getItemQuantity();
    		if(null == itemQuantity || "".equals(itemQuantity.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemQuantity必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setItemQuantity(new BigDecimal(itemQuantity));
    		
    		String itemPrice = itemBean.getItemPrice();
    		if(null == itemPrice || "".equals(itemPrice.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemPrice必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setItemPrice(new BigDecimal(itemPrice));
    		
    		String marketPrice = itemBean.getMarketPrice();
        	if(null != marketPrice && !"".equals(marketPrice.trim())) {
        		omsOrderItem.setMarketPrice(new BigDecimal(marketPrice));
        	}
        	
        	String itemDiscounted = itemBean.getItemDiscounted();
        	if(null != itemDiscounted && !"".equals(itemDiscounted.trim())) {
        		omsOrderItem.setItemDiscounted(new BigDecimal(itemDiscounted));
        	}
        	
        	String memberPrice = itemBean.getMemberPrice();
        	if(null != memberPrice && !"".equals(memberPrice.trim())) {
        		omsOrderItem.setMemberPrice(new BigDecimal(itemBean.getMemberPrice()));
        	}
    		
    		String apportionAmount = itemBean.getApportionAmount();
    		if(null == apportionAmount || "".equals(apportionAmount.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("apportionAmount必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setApportionAmount(new BigDecimal(apportionAmount));
    		
    		String apportionAmountUnit = itemBean.getApportionAmountUnit();
    		if(null == apportionAmountUnit || "".equals(apportionAmountUnit.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("apportionAmountUnit必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setApportionAmountUnit(new BigDecimal(apportionAmountUnit));
    		
    		omsOrderItem.setVirtualSku(itemBean.getVirtualSku());
    		
    		String virtualQty = itemBean.getVirtualQty();
    		if(null != virtualQty && !"".equals(virtualQty.trim())) {
    			omsOrderItem.setVirtualQty(new BigDecimal(virtualQty));
    		}
    		
    		omsOrderItem.setVirtualName(itemBean.getVirtualName());
    		omsOrderItem.setVirtualStandard(itemBean.getVirtualStyle());
    		omsOrderItem.setVirtualWeight(itemBean.getVirtualWeight());
    		
    		String virtualAmount = itemBean.getVirtualAmount();
    		if(null != virtualAmount && !"".equals(virtualAmount.trim())) {
    			omsOrderItem.setVirtualAmount(new BigDecimal(virtualAmount));
    		}
    		
    		String virtualAmountUnit = itemBean.getVirtualAmountUnit();
    		if(null != virtualAmountUnit && !"".equals(virtualAmountUnit.trim())) {
    			omsOrderItem.setVitualAmountUnit(new BigDecimal(virtualAmountUnit));
    		}
    		
    		omsOrderItem.setPromotionCode(itemBean.getPromotionCode());
    		omsOrderItem.setPromotionName(itemBean.getPromotionName());
    		omsOrderItem.setPromotionDesc(itemBean.getPromotionDesc());
    		
    		String promotionType = itemBean.getPromotionType();
//    		if(null == promotionType || "".equals(promotionType.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("promotionType必填项不能为空");
//                return _return;
//        	}	
    		omsOrderItem.setPromotionType(promotionType);
    		
    		String promotionPriority = itemBean.getPromotionPriority();
    		if(null != promotionPriority && !"".equals(promotionPriority.trim())) {
    			omsOrderItem.setPromotionPriority(new BigDecimal(promotionPriority));
    		}
    		
    		String unitId = itemBean.getUnitId();
    		if(null == unitId || "".equals(unitId.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("unitId必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setUnitId(new BigDecimal(unitId));
    		
    		String parentUnitId = itemBean.getParentUnitId();
    		if(null == parentUnitId || "".equals(parentUnitId.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("parentUnitId必填项不能为空");
                return _return;
        	}	
    		omsOrderItem.setParentUnitId(new BigDecimal(parentUnitId));
    		
    		omsOrderItem.setHybrisSequenceNo(unitId);
    		
    		omsOrderItemList.add(omsOrderItem);
		}
    	omsOrder.getOmsOrderItems().addAll(omsOrderItemList);
    	
    	List<HybrisOrderPromoNewBean> hybrisOrderPromoBeans = arg0.getHybrisOrderPromoBeans();
    	if(null == hybrisOrderPromoBeans || hybrisOrderPromoBeans.size() == 0) {
    		_return.setResultCode("5002");
            _return.setResutlDesc("hybrisOrderPromoBeans必填项不能为空");
            return _return;
    	}
    	List<OmsOrderPromo> omsOrderPromosList = new ArrayList<OmsOrderPromo>();
    	for (HybrisOrderPromoNewBean promoBean : hybrisOrderPromoBeans) {
    		OmsOrderPromo omsOrderPromo = new OmsOrderPromo();
    		
    		String promotionCode = promoBean.getPromotionCode();
    		if(null == promotionCode || "".equals(promotionCode.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("promotionCode必填项不能为空");
                return _return;
        	}	
    		omsOrderPromo.setSourcePromotionCode(promotionCode);
    		
    		String promotionName = promoBean.getPromotionName();
    		if(null == promotionName || "".equals(promotionName.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("promotionName必填项不能为空");
                return _return;
        	}	
    		omsOrderPromo.setSourcePromotionName(promotionName);
    		
    		String startTime = promoBean.getStartTime();
//    		if(null == startTime || "".equals(startTime.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("startTime必填项不能为空");
//                return _return;
//    		}
    		String endTime = promoBean.getEndTime();
//    		if(null == endTime || "".equals(endTime.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("endTime必填项不能为空");
//                return _return;
//        	}	
    		
    		try {
    			if(null != startTime && !"".equals(startTime.trim())) {
    				omsOrderPromo.setStartTime(format.parse(startTime));
    			}
				if(null != endTime && !"".equals(endTime.trim())) {
					omsOrderPromo.setEndTime(format.parse(endTime));
				}
			} catch (ParseException e) {
				_return.setResultCode("5003");
	            _return.setResutlDesc("startTime/endTime数据类型或长度错误");
				e.printStackTrace();
				return _return;
			}
    		
    		omsOrderPromo.setApportionRule(promoBean.getApportionRule());
    		
    		String itemSku = promoBean.getItemSku();
    		if(null == itemSku || "".equals(itemSku.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemSku必填项不能为空");
                return _return;
        	}	
    		omsOrderPromo.setItemSku(itemSku);
    		
    		String itemName = promoBean.getItemName();
    		if(null == itemName || "".equals(itemName.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("itemName必填项不能为空");
                return _return;
        	}	
    		omsOrderPromo.setItemName(itemName);
    		
    		String originalPrice = promoBean.getOriginalPrice();
    		if(null == originalPrice || "".equals(originalPrice.trim())) {
        		_return.setResultCode("5002");
                _return.setResutlDesc("originalPrice必填项不能为空");
                return _return;
        	}	
    		omsOrderPromo.setOriginalPrice(new BigDecimal(originalPrice));
    		
    		omsOrderPromo.setVirtualItemSku(promoBean.getVirtualItemSku());
    		omsOrderPromo.setVirtualItemName(promoBean.getVirtualItemName());
    		
    		String virtualOriginalPrice = promoBean.getVirtualOriginalPrice();
    		if(null != virtualOriginalPrice && !"".equals(virtualOriginalPrice.trim())) {
    			omsOrderPromo.setVirtualOriginalPrice(new BigDecimal(virtualOriginalPrice));
    		}
    		
    		String itemSequenceNo = promoBean.getItemSequenceNo();
//    		if(null == itemSequenceNo || "".equals(itemSequenceNo.trim())) {
//        		_return.setResultCode("5002");
//                _return.setResutlDesc("itemSequenceNo必填项不能为空");
//                return _return;
//        	}	
    		omsOrderPromo.setItemSequenceNo(itemSequenceNo);
    		
    		String freePostAmount = promoBean.getFreePostAmount();
    		if(null != freePostAmount && !"".equals(freePostAmount.trim())) {
    			omsOrderPromo.setFreePostAmount(new BigDecimal(freePostAmount));
    		}
    		
    		omsOrderPromosList.add(omsOrderPromo);
		}
    	omsOrder.getOmsOrderPromos().addAll(omsOrderPromosList);
    	
    	List<HybrisCouponBean> couponBeans = arg0.getHybrisCouponBeans();
    	if(null != couponBeans && couponBeans.size() > 0) {
	    	List<HysbrisCoupon> couponList = new ArrayList<HysbrisCoupon>();
	    	
	    	for (HybrisCouponBean couponBean : couponBeans) {
	    		HysbrisCoupon hysbrisCoupon = new HysbrisCoupon();
	    		
	    		String couponCode = couponBean.getCouponCode();
	    		if(null == couponCode || "".equals(couponCode.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("couponCode必填项不能为空");
	                return _return;
	        	}	
	    		hysbrisCoupon.setCouponCode(couponCode);
	    		
	    		String couponType = couponBean.getCouponType();
	    		if(null == couponType || "".equals(couponType.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("couponType必填项不能为空");
	                return _return;
	        	}	
	    		hysbrisCoupon.setCouponType(couponType);
	    		
	    		String couponStatus = couponBean.getCouponStatus();
	    		if(null == couponStatus || "".equals(couponStatus.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("couponStatus必填项不能为空");
	                return _return;
	        	}	
	    		hysbrisCoupon.setCouponStatus(couponStatus);
	    		
	    		hysbrisCoupon.setAccountNo(couponBean.getAccountNo());
	    		
	    		String startTime = couponBean.getStartTime();
	    		if(null != startTime && !"".equals(startTime.trim())) {
	    			try {
						hysbrisCoupon.setStartTime(format.parse(startTime));
					} catch (ParseException e) {
						_return.setResultCode("5003");
			            _return.setResutlDesc("startTime数据类型或长度错误");
						e.printStackTrace();
						return _return;
					}
	    		}
	    		
	    		String endTime = couponBean.getEndTime();
	    		if(null != endTime && !"".equals(endTime.trim())) {
	    			try {
						hysbrisCoupon.setEndTime(format.parse(endTime));
					} catch (ParseException e) {
						_return.setResultCode("5003");
			            _return.setResutlDesc("endTime数据类型或长度错误");
						e.printStackTrace();
						return _return;
					}
	    		}
	    		
	    		String amount = couponBean.getAmount();
	    		if(null ==  amount || "".equals(amount.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("amount必填项不能为空");
	                return _return;
	        	}	
	    		hysbrisCoupon.setAmount(new BigDecimal(amount));
	    		
	    		hysbrisCoupon.setCostSource(couponBean.getCostSource());
	    		
	    		couponList.add(hysbrisCoupon);
	    	}
	    	omsOrder.getHysbrisCoupons().addAll(couponList);
    	}
    	
    	
    	List<HybrisMemberPointAccountBean> memberPointAccountBeans = arg0.getHybrisMemberPointAccountBeans();
    	if(null != memberPointAccountBeans && memberPointAccountBeans.size() > 0) {
	    	List<HybrisMemberPointAccount> memberPointAccountList = new ArrayList<HybrisMemberPointAccount>();
	    	
	    	for (HybrisMemberPointAccountBean memberPointAccountBean : memberPointAccountBeans) {
	    		HybrisMemberPointAccount hybrisMemberPointAccount = new HybrisMemberPointAccount();
	    		
	    		String accountCode = memberPointAccountBean.getAccountCode();
	    		if(null == accountCode || "".equals(accountCode.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("accountCode必填项不能为空");
	                return _return;
	        	}	
	    		hybrisMemberPointAccount.setAccountCode(accountCode);
	    		
	    		String redeemPoint = memberPointAccountBean.getRedeemPoint();
	    		if(null != redeemPoint && !"".equals(redeemPoint.trim())) {
	    			hybrisMemberPointAccount.setRedeemPoint(new BigDecimal(redeemPoint));
	    		}
	    		
	    		String earnPoint = memberPointAccountBean.getEarnPoint();
	    		if(null != earnPoint && !"".equals(earnPoint.trim())) {
	    			hybrisMemberPointAccount.setEarnPoint(new BigDecimal(earnPoint));
	    		}
	    		
	    		memberPointAccountList.add(hybrisMemberPointAccount);
	    	}
	    	omsOrder.getHybrisMemberPointAccount().addAll(memberPointAccountList);
    	}
    	
    	List<HybrisItemRebateBean> hybrisItemRebateBeans = arg0.getHybrisItemRebateBeans();
    	if(null != hybrisItemRebateBeans && hybrisItemRebateBeans.size() > 0) {
	    	List<HybrisItemRebate> hybrisItemRebatesList = new ArrayList<HybrisItemRebate>();
	    	
	    	for (HybrisItemRebateBean hybrisItemRebateBean : hybrisItemRebateBeans) {
	    		HybrisItemRebate hybrisItemRebate = new HybrisItemRebate();
	    		
	    		String channelName = hybrisItemRebateBean.getChannelName();
	    		if(null == channelName || "".equals(channelName.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("channelName必填项不能为空");
	                return _return;
	        	}	
	    		hybrisItemRebate.setChannelName(channelName);
	    		
	    		String itemSku = hybrisItemRebateBean.getItemSku();
	    		if(null == itemSku || "".equals(itemSku.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("itemSku必填项不能为空");
	                return _return;
	        	}	
	    		hybrisItemRebate.setItemSku(itemSku);
	    		
	    		String itemCommissionRate = hybrisItemRebateBean.getItemCommissionRate();
	    		if(null == itemCommissionRate || "".equals(itemCommissionRate.trim())) {
	        		_return.setResultCode("5002");
	                _return.setResutlDesc("itemCommissionRate必填项不能为空");
	                return _return;
	        	}	
	    		hybrisItemRebate.setItemCommissionRate(new BigDecimal(itemCommissionRate));
	    		
	    		hybrisItemRebatesList.add(hybrisItemRebate);
	    	}
	    	omsOrder.getHybrisItemRebate().addAll(hybrisItemRebatesList);
    	}
    	
    	//
        omsOrder.setOmsOrderNo(getUUID());
        omsOrder.setOmsOrderSysId(getUUID());
        omsOrder.setOrderType("NORMAL");
        omsOrder.setIsNeedBook("1");
        omsOrder.setOrderStatus("WAIT_STKOUT");
        omsOrder.setStoreId("1888");
        
        modfiyOrderStatus(omsOrder.getWatsonsOrderNo(), "SHIPPING", null);
        
        return orderDao.syncOrder(omsOrder);
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#cancelOrder(java.lang.String  hybrisOrderNo ,)java.lang.String  reasonCode ,)java.lang.String  comment )*
     */
    public com.eos.wms.webservice.ResponseBean cancelOrder(java.lang.String hybrisOrderNo,java.lang.String reasonCode,java.lang.String comment) { 
        LOG.info("Executing operation cancelOrder");
        System.out.println(hybrisOrderNo);
        System.out.println(reasonCode);
        System.out.println(comment);
        try {
            com.eos.wms.webservice.ResponseBean _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#pushCoupon(java.util.List<com.eos.wms.webservice.HybrisCouponBean>  arg0 )*
     */
    public com.eos.wms.webservice.ResponseBean pushCoupon(java.util.List<com.eos.wms.webservice.HybrisCouponBean> arg0) { 
        LOG.info("Executing operation pushCoupon");
        System.out.println(arg0);
        try {
            com.eos.wms.webservice.ResponseBean _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#listByMemberAndOrder(java.lang.String  orderMemberId ,)java.lang.String  hybrisOrderNo )*
     */
    public java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> listByMemberAndOrder(java.lang.String orderMemberId,java.lang.String hybrisOrderNo) { 
        LOG.info("Executing operation listByMemberAndOrder");
        System.out.println(orderMemberId);
        System.out.println(hybrisOrderNo);
        try {
            java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#pushReturn(com.eos.wms.webservice.HybrisOrderReturnBean  arg0 )*
     */
    public com.eos.wms.webservice.ResponseBean pushReturn(com.eos.wms.webservice.HybrisOrderReturnBean arg0) { 
        LOG.info("Executing operation pushReturn");
        System.out.println(arg0);
        try {
            com.eos.wms.webservice.ResponseBean _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.eos.wms.webservice.OrderWebService#searchBySequenceNo(java.lang.String  itemSequenceNo )*
     */
    public com.eos.wms.webservice.ItemDetail searchBySequenceNo(java.lang.String itemSequenceNo) { 
        LOG.info("Executing operation searchBySequenceNo");
        System.out.println(itemSequenceNo);
        try {
            com.eos.wms.webservice.ItemDetail _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }
    
    public static String getUUID() {
		String id = UUID.randomUUID().toString();
		// 去掉“-”符号
		return id.replaceAll("-", "");
	}
    
    
    /**
     * This method call hybris interface to notify order's status and shipping info. 
     * 
     * @param orderCode: order No, don't allow empty
     * @param status:    order Status , don't allow empty
     * @param shippDescription ; allow empty 
     */
    private void modfiyOrderStatus(String orderCode, String status, String shippDescription) {
    	// properties key for hybris server 
    	String  keyHybrisDomain = "hybris.domain";
    	String hybrisDomainUrl = null;
    	
    	if (null == orderCode || "".equals(orderCode)
				|| null == status || "".equals(status)) {
    		LOG.info("Order No or Status is empty.");
			return;
		}
    	
		try {
			org.springframework.core.io.Resource resource = new ClassPathResource("/wtceos.properties");
			Properties props = PropertiesLoaderUtils.loadProperties(resource);
			hybrisDomainUrl = props.getProperty(keyHybrisDomain);
			
			if (null == hybrisDomainUrl || "".equals(hybrisDomainUrl)) {
				LOG.info("The configuration hybris.domain is undefined.");
				return;
			}
		} catch (IOException e) {
			LOG.info("Read wtceos.properties failed.");
			e.printStackTrace();
			return;
		}
		
    	try {
    		if (hybrisDomainUrl != null && !"".equals(hybrisDomainUrl)) {
    			String hybrisUpdateStatusUrl = hybrisDomainUrl + "/infinitycommercewebservices/v1/orders/update";
    			String requstParm = "code=" + orderCode +"&statusCode=" + status;
    			
    			if (null != shippDescription || !"".equals(shippDescription)) {
    				shippDescription = URLEncoder.encode(shippDescription, "UTF-8");
    				requstParm = requstParm + "&infinityShippDescription=" + shippDescription;
    			}
    			
    			
    			URL url =new URL(hybrisUpdateStatusUrl);
    	        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    	        conn.setDoOutput(true);
    	        conn.setDoInput(true);
    	        conn.setConnectTimeout(5*1000);
    	        conn.setRequestMethod("POST");
    	        conn.setUseCaches(false);
    	        conn.setInstanceFollowRedirects(true);
    	        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    	        conn.connect();
    	        
    	        DataOutputStream dataout = new DataOutputStream(conn.getOutputStream());
    	        dataout.writeBytes(requstParm);
    	        dataout.flush();
                dataout.close();
                
                if (conn.getResponseCode()==200){
                	BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
        	        
        	        String line;
                    StringBuilder sb = new StringBuilder();
                    while ((line = br.readLine()) != null) {
                        sb.append(line);
                    }
                    if (null == sb.toString() || "".equals(sb.toString())) {
                    	LOG.info("Hybris update status failed.");
                    }
                    
                    br.close();
                } else {
                	LOG.info("Update Order Status Response Failed.");
                }
    	        
                conn.disconnect();
    		}
		} catch (IOException e) {
			LOG.info("Send Update Order Status Request Failed.");
			e.printStackTrace();
		}
    	
    }

}

4. OrderWebService

package com.eos.wms.webservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

/**
 * This class was generated by Apache CXF 3.1.0
 * 2015-06-11T13:54:22.380+08:00
 * Generated source version: 3.1.0
 * 
 */
@WebService(targetNamespace = "http://interfaces.cxf.com/", name = "OrderWebService")
@XmlSeeAlso({ObjectFactory.class})
public interface OrderWebService {

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "searchReturnByMemberId", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchReturnByMemberId")
    @WebMethod
    @ResponseWrapper(localName = "searchReturnByMemberIdResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchReturnByMemberIdResponse")
    public java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> searchReturnByMemberId(
        @WebParam(name = "orderMemberId", targetNamespace = "")
        java.lang.String orderMemberId
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "syncCoupon", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SyncCoupon")
    @WebMethod
    @ResponseWrapper(localName = "syncCouponResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SyncCouponResponse")
    public com.eos.wms.webservice.ResponseBean syncCoupon(
        @WebParam(name = "arg0", targetNamespace = "")
        com.eos.wms.webservice.HybrisCouponBean arg0
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "searchOrderStats", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchOrderStats")
    @WebMethod
    @ResponseWrapper(localName = "searchOrderStatsResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchOrderStatsResponse")
    public java.lang.String searchOrderStats(
        @WebParam(name = "hybrisOrderNo", targetNamespace = "")
        java.lang.String hybrisOrderNo
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "searchOrder", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchOrder")
    @WebMethod
    @ResponseWrapper(localName = "searchOrderResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchOrderResponse")
    public com.eos.wms.webservice.OmsOrderForHybris searchOrder(
        @WebParam(name = "hybrisOrderNo", targetNamespace = "")
        java.lang.String hybrisOrderNo
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "searchReturnByReturnNo", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchReturnByReturnNo")
    @WebMethod
    @ResponseWrapper(localName = "searchReturnByReturnNoResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchReturnByReturnNoResponse")
    public com.eos.wms.webservice.HybrisOrderReturnBean searchReturnByReturnNo(
        @WebParam(name = "omsOrderReturnNo", targetNamespace = "")
        java.lang.String omsOrderReturnNo
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "syncOrder", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SyncOrder")
    @WebMethod
    @ResponseWrapper(localName = "syncOrderResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SyncOrderResponse")
    public com.eos.wms.webservice.ResponseBean syncOrder(
        @WebParam(name = "arg0", targetNamespace = "")
        com.eos.wms.webservice.HybrisOrderNewBean arg0,
        @WebParam(name = "arg1", targetNamespace = "")
        com.eos.wms.webservice.UserInfoBean arg1
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "cancelOrder", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.CancelOrder")
    @WebMethod
    @ResponseWrapper(localName = "cancelOrderResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.CancelOrderResponse")
    public com.eos.wms.webservice.ResponseBean cancelOrder(
        @WebParam(name = "hybrisOrderNo", targetNamespace = "")
        java.lang.String hybrisOrderNo,
        @WebParam(name = "reasonCode", targetNamespace = "")
        java.lang.String reasonCode,
        @WebParam(name = "comment", targetNamespace = "")
        java.lang.String comment
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "pushCoupon", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.PushCoupon")
    @WebMethod
    @ResponseWrapper(localName = "pushCouponResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.PushCouponResponse")
    public com.eos.wms.webservice.ResponseBean pushCoupon(
        @WebParam(name = "arg0", targetNamespace = "")
        java.util.List<com.eos.wms.webservice.HybrisCouponBean> arg0
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "listByMemberAndOrder", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.ListByMemberAndOrder")
    @WebMethod
    @ResponseWrapper(localName = "listByMemberAndOrderResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.ListByMemberAndOrderResponse")
    public java.util.List<com.eos.wms.webservice.HybrisOrderReturnBean> listByMemberAndOrder(
        @WebParam(name = "orderMemberId", targetNamespace = "")
        java.lang.String orderMemberId,
        @WebParam(name = "hybrisOrderNo", targetNamespace = "")
        java.lang.String hybrisOrderNo
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "pushReturn", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.PushReturn")
    @WebMethod
    @ResponseWrapper(localName = "pushReturnResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.PushReturnResponse")
    public com.eos.wms.webservice.ResponseBean pushReturn(
        @WebParam(name = "arg0", targetNamespace = "")
        com.eos.wms.webservice.HybrisOrderReturnBean arg0
    );

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "searchBySequenceNo", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchBySequenceNo")
    @WebMethod
    @ResponseWrapper(localName = "searchBySequenceNoResponse", targetNamespace = "http://service.wtc.goms.com/", className = "com.eos.wms.webservice.SearchBySequenceNoResponse")
    public com.eos.wms.webservice.ItemDetail searchBySequenceNo(
        @WebParam(name = "ItemSequenceNo", targetNamespace = "")
        java.lang.String itemSequenceNo
    );
    
    
    @WebMethod
    public java.lang.String updateOrderStats(
        @WebParam(name = "orderCode", targetNamespace = "")
        java.lang.String orderCode,
        @WebParam(name = "status", targetNamespace = "")
        java.lang.String status,
        @WebParam(name = "shippDescription", targetNamespace = "")
        java.lang.String shippDescription
    );
}

 二、客户调用

	//TODO 移到下面去根据success来调用保证事务性
		webserviceUtil.setServiceName("OrderWebService");
		webserviceUtil.setOperationName("updateOrderStats");
		webserviceUtil.invokeWs(orderNo,CommonUtil.OrderStatus.ACTIVE,"");

 2.WebserviceUtil工具方法

package com.gomsws.util;

import java.util.HashMap;
import java.util.Map;



import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

/**
 * 
 * @author wiggins
 * @date 2015-6-30
 * 
 */
public class WebserviceUtil {

	private static Logger logger = LoggerFactory
			.getLogger(WebserviceUtil.class);

	private String ip = "";
	private String port = "";
	private String serviceName = "";
	private String operationName = "";

	public void invokeWs(String orderCode, String status,
			String shippDescription) throws Exception {
		JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory
				.newInstance();
		Client client = clientFactory.createClient(getUrl());
		Object[] result = client.invoke(operationName, new String[] {
				orderCode, status, shippDescription });
	}

	public String getUrl() throws Exception {
		if (!StringUtils.hasText(getIp())) {
			logger.error("ip empty");
			throw new Exception("url empty");
		}
		if (!StringUtils.hasText(getPort())) {
			logger.error("port empty");
			throw new Exception("port empty");
		}
		if (!StringUtils.hasText(getServiceName())) {
			logger.error("serviceName empty");
			throw new Exception("serviceName empty");
		}
		return "http://" + getIp() + ":" + getPort() + "/wms/webservice/"
				+ getServiceName() + "?wsdl";
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getOperationName() {
		return operationName;
	}

	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}
	
	

}

 3.webserviceUtil给spring管理

<bean id="webserviceUtil"
		class="com.gomsws.util.WebserviceUtil">
		<property name="ip">
			<value>172.17.17.95</value>
		</property>
		<property name="port">
			<value>8090</value>
		</property>
	</bean>

 

你可能感兴趣的:(使用CXF,注解,一个简单的webservice例子)