`

使用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>

 

分享到:
评论

相关推荐

    webService(基于cxf)的完整例子

    例如,可以使用`@WebService`注解标记一个Java类为Web服务接口,并使用`@Path`注解来定义RESTful服务的URL路径。 4. **CXF服务部署**:CXF提供多种部署方式,包括独立服务器、Tomcat等应用服务器,以及Spring容器。...

    Spring + CXF + 注解方式(webService)

    Apache CXF是一个开源的服务框架,它允许开发者创建和消费各种不同类型的Web服务,而Spring则是一个广泛使用的Java企业级应用框架,它提供了强大的依赖注入和AOP(面向切面编程)功能。接下来,我们将深入探讨这两个...

    webservice天气预报例子cxf实例

    在本例中,“webservice天气预报例子cxf实例”指的是使用Apache CXF框架实现的一个天气预报相关的Web服务示例。 Apache CXF是一个开源框架,它为开发和部署Web服务提供了全面的支持。CXF允许开发者通过Java编程模型...

    cxf webService简单例子

    【标题】"cxf webService简单例子"是一个关于使用Apache CXF框架创建和消费Web服务的基础教程。Apache CXF是一个开源的Java框架,它允许开发者创建和实现符合各种Web服务标准(如SOAP、RESTful)的服务。这个例子将...

    springboot整合CXF发布webservice和客户端调用

    - 创建一个服务接口,使用JAX-WS注解如`@WebService`来标记,定义服务的方法。 - 实现服务接口,并使用`@WebService(serviceName = "...")`标记实现类。 - 在SpringBoot主类中,使用`@EnableCxfRsServer`开启CXF...

    使用 CXF 做 webservice 简单例子

    在本例中,创建了一个简单的 `sayHello` 方法,接收一个名为 `name` 的参数并返回问候语。 在 web.xml 文件中,配置 CXF 的上下文参数和监听器,指定 Spring 配置文件的位置(例如 WEB-INF/service-beans.xml),...

    cxf+spring实现webservice例子

    总的来说,这个例子展示了如何利用CXF和Spring的强大功能创建一个简单的Web服务。在实际开发中,你可以根据需求扩展服务功能,实现更复杂的业务逻辑,同时享受到这两个框架带来的便利性和灵活性。

    CXF发布restful WebService的入门例子.pdf

    在本入门例子中,我们将使用CXF来发布一个RESTful WebService,以管理房间和居住在房间内的人物。 1. **POJO对象定义**: 在RESTful WebService中,数据通常以Java对象(POJO)的形式进行处理。这里的`Person`和`...

    webservice cxf 服务端客户端传递参数的例子demo

    CXF是一个Java框架,它允许开发者通过简单的API来创建和使用Web服务。CXF支持多种Web服务标准,如WS-I Basic Profile、WS-Security等,并且可以与Spring框架无缝集成。它提供了SOAP和RESTful两种服务模式,使得...

    较完整的webservice例子

    尽管描述为空,但我们可以从标题推测,这个压缩包可能包含一个或多个示例程序,用于演示如何创建和使用Web Service。通常,这样的例子会包括服务端的代码,客户端的代码,以及可能的配置文件,帮助开发者学习如何...

    Spring+CXF 全注解版

    Apache CXF是一个开源的服务框架,它允许开发者创建和消费各种Web服务,而Spring框架则是一个广泛使用的依赖注入(DI)和面向切面编程(AOP)工具,两者结合可以提供一个高效、灵活的服务实现环境。 **1. Spring...

    cxf 实现的webservice例子demo

    3. **服务接口和服务实现**:在源代码中,定义了一个Web服务接口,通常使用JAX-WS的`@WebService`注解标记。接口的实现类提供了具体的服务逻辑,实现了接口中声明的方法。 4. **服务发布**:CXF使用Spring框架来...

    基于webservice实现的一个CXF例子

    **基于Webservice实现的一个CXF例子** Web服务(Web Service)是一种通过互联网交换业务逻辑的软件系统,它允许应用程序在不同的平台之间共享数据和服务。Java世界中的Webservice实现有很多,如JAX-WS(Java API ...

    cxf webservice例子

    总之,“cxf webservice例子”是一个宝贵的教育资源,对于想要学习或提升CXF Web服务开发技能的人来说,这是一个很好的实践平台。通过深入研究和理解这些例子,开发者可以掌握如何使用CXF来构建高效、安全的Web服务...

    webservice cxf 整合spring例子源代码

    3. **服务接口与实现**:定义Web服务的接口,通常是一个JAX-WS的@WebService注解的Java接口。接口的实现类则提供具体的功能。Spring可以帮助管理这些bean,包括依赖注入和事务控制。 4. **发布Web服务**:在Spring...

    CXF webservice Demo

    总的来说,"CXF Webservice Demo"是一个学习和实践使用Apache CXF创建和使用SOAP Web服务的好例子。它涵盖了从服务定义、实现到客户端调用的整个流程,对于理解和掌握CXF框架的功能和用法非常有帮助。通过这个示例,...

    CXF的例子WebService

    CXF,全称CXF Common Service Framework,是一个开源的Java Web服务框架,用于构建和开发SOAP(简单对象访问协议)和RESTful(Representational State Transfer)服务。CXF提供了丰富的功能,包括WS-*协议支持、数据...

    CXF+Spring发布webservice服务的例子

    在Java中,我们可以使用JAX-WS(Java API for XML Web Services)标准来创建一个@WebService注解的接口。例如: ```java import javax.jws.WebService; @WebService public interface HelloWorldService { String...

    webService cxf 例子

    综上所述,"webService cxf 例子"是一个展示如何使用Apache CXF框架开发和测试Web服务的实际示例。通过学习和实践这些例子,开发者可以深入理解CXF的工作原理,以及如何利用其功能创建高效、安全的Web服务。

    webservice xfire整合spring(webservice配置采用注解)例子

    【标题】中的“webservice xfire整合spring(webservice配置采用注解)”是指将Xfire,一个早期的Web服务框架,与Spring框架结合使用,其中Web服务的配置通过Spring的注解方式进行。这种方式简化了配置,提高了开发...

Global site tag (gtag.js) - Google Analytics