联通sp对接填坑备忘

联通vac和sp对接填坑备忘


坑很多,平时我也不写webservice,联通配合的哥们说来说去就是:“按规范”,这简直就是最高指示:“按既定方针办”。没办法只能自己苦逼的多试试。

建议联通参考参考微信公众平台上面的,有个文档,有个服务端填写,也搞个论坛能提问。

闲话少说,规范一共2点,一个webservice,一个ftp :

  • ftp这个真心不好理解,啥发起方vac,接受方sp,文件头格式文件体格式,绕的晕头转向的,其实就是他们有一个ftp服务器,咱们定期去考文件回来按照文件头文件体解析,这一块可以先不管,以后再填坑

  • webservice这一块报文demo如下



    
        
            
                201310281653151945
                1
                18628071120
                80
                90120
                9081086801
                1
                20150326153832
                
                
                
                
                20370101000000
                1028165315
                1862807112090810868011028165315
            
        
    

字段名称并不和文档一模一样,我是先拿到文档的,按照文档写了对象,对不起,测试的时候找不到字段滴,主要就是Id和ID区别,其他倒还好

搭建maven + cxf + spring项目

新建一个maven项目,

pom.xml添加需要的jar

2.7.13

---

 
         org.apache.cxf 
         cxf-rt-frontend-jaxws 
         ${cxf.version} 
 
 
         org.apache.cxf 
         cxf-rt-transports-http 
         ${cxf.version} 
 
 
         org.apache.cxf 
         cxf-rt-transports-http-jetty 
         ${cxf.version} 
 
 
         org.apache.cxf 
         cxf-rt-ws-security 
         ${cxf.version} 
 
 
         org.apache.cxf 
         cxf-rt-ws-policy 
         ${cxf.version} 
 
 
         org.apache.cxf 
         cxf-bundle-jaxrs 
         ${cxf.version} 
 
 
         javax.ws.rs 
         jsr311-api 
         1.1.1 

web.xml




    dingzl test
    
        index
    
      
        org.springframework.web.context.ContextLoaderListener  
      
      
      
        contextConfigLocation  
        classpath*:applicationContext.xml  
      
      
        org.springframework.web.context.ContextLoaderListener  
      
      
        CXFService  
        org.apache.cxf.transport.servlet.CXFServlet  
      
      
        CXFService  
        /*  
      

applicationContext.xml



        
    
    
    
    
     
   
 
 

建java接口文件

这时候需要能看懂demo的xml报文,我就是走了很多弯路


            

这里文件夹按照soap.bossagent.vac.unicom.com来建,com/unicom/vac/bossagent/soap下面建java文件,

路径 :../src/main/java/com/unicom/vac/bossagent/soap/IOrderRelationUpdateNotify.java

package com.unicom.vac.bossagent.soap;
import javax.jws.WebParam;
import javax.jws.WebService; 
import javax.jws.WebMethod;

@WebService(targetNamespace = "http://soap.bossagent.vac.unicom.com")
public interface IOrderRelationUpdateNotify {
    @WebMethod(operationName="orderRelationUpdateNotify")
     public Rsp orderRelationUpdateNotify(@WebParam(name="orderRelationUpdateNotifyRequest") OrderRelationUpdateNotifyRequest req); 
     
    
}

targetNamespace 这个困惑我好久.没有这个的时候,报文http://soap.bossagent.vac.uni... 带上斜杠"/"的时候是能找到.

但是没有斜杠的时候一直报 Unexpected wrapper element {http://soap.bossagent.vac.uni...}orderRelationUpdateNotify found. Expected {http://soap.bossagent.vac.uni...}orderRelationUpdateNotify.
后来加上targetNamespace 就好了

实现类

路径 :../src/main/java/com/unicom/vac/bossagent/soap/OrderRelationUpdateNotifyImpl.java

package com.unicom.vac.bossagent.soap;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService; 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


@WebService
public class OrderRelationUpdateNotifyImpl implements IOrderRelationUpdateNotify {  
    private static final Logger logger = LogManager.getLogger(OrderRelationUpdateNotifyImpl.class);
    
    @WebMethod(operationName="orderRelationUpdateNotify")
    public Rsp orderRelationUpdateNotify(@WebParam(name="orderRelationUpdateNotifyRequest") OrderRelationUpdateNotifyRequest req) {  
        logger.info(req.toString());
        
        Rsp rsp = new Rsp();
        rsp.setRecordSequenceID(req.getRecordSequenceId());
        rsp.setResultCode(0);
        return rsp;  
    }
}

入参对象

package com.unicom.vac.bossagent.soap;

public class OrderRelationUpdateNotifyRequest {
    private String  recordSequenceId;//    string    18    流水号, 
    private Integer userIdType;//    integer    4    用户ID类型    1: MSISDN    2: PsedoCode
    private String  userId;//    string    36    用户手机号码或伪码 UserIdType填1 为手机号码;    UserIdType填2 为伪码

    private String  serviceType;//    String    2    业务类型,见附录
    private String spId;//    string    21    SP标识
    private String productId;//    string    21    产品标识(此为SP在PRM侧申请的SP_Productid)
    private Integer updateType;//    integer    4    更新操作的类型包括:    1:订购    2:退定    3:点播    4:定购关系变更(一般是修改有效期)(保留,暂不用)    5:改号

    private String updateTime;//    string    14    更新时间
    private String updateDesc;//    string    100    更新操作的详细描述    联通在信、彩信等定购、点播接入号,和CheckPrice请求中AccessNo字段一致;    对crm侧订购、退订由vac根据产品填写;对其他业务填空

    private String linkId;//    string    20    事务关联ID,用于点播业务的临时定购关系关联,由平台产生。格式如下:    MMDDHHMMSS+10位随机序列号;    为空表示无效。    用户点播时使用。

    private String content;//    string    140    内容,当UpdateType=5时,本字段填原用户手机号码或伪码,具体填写方式由UserIdType字段决定
    private String effectiveDate;//    string    14    订购关系生效时间, 格式:yyyyMMddhhmmss
    private String expireDate;//    string    14    订购关系失效时间, 格式:yyyyMMddhhmmss
    private String time_stamp;//    string    10    时间戳由VAC生成,格式是: MMDDHHMMSS,月日时分秒。
    private String encodeStr;//    string
.....get/set略。。。

这里和文档略有区别,要注意

返回值对象

package com.unicom.vac.bossagent.soap;
/**
 * 返回值
 * @author dingzl10
 *
 */
public class Rsp {
    private String  recordSequenceID;
    private Integer resultCode;
    
    
    public String getRecordSequenceID() {
        return recordSequenceID;
    }
    public void setRecordSequenceID(String recordSequenceID) {
        this.recordSequenceID = recordSequenceID;
    }
    public Integer getResultCode() {
        return resultCode;
    }
    public void setResultCode(Integer resultCode) {
        this.resultCode = resultCode;
    }
    @Override
    public String toString() {
        return "Rsp [recordSequenceID=" + recordSequenceID + ", resultCode=" + resultCode + "]";
    }

    
    
}

部署&测试

部署的时候呢,对方是不接受域名的,一定要ip和端口,这个要注意
测试
代码测试很容易就通过了

public static void main(String[] args) {
            
        JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean();
        svr.setServiceClass(IOrderRelationUpdateNotify.class);
        
        svr.setAddress("http://localhost:8080/sp/OrderRelationUpdateNotify");
        IOrderRelationUpdateNotify hw = (IOrderRelationUpdateNotify) svr.create();
        OrderRelationUpdateNotifyRequest  r = new OrderRelationUpdateNotifyRequest();
        r.setRecordSequenceId("111111111");
        System.out.println(hw.orderRelationUpdateNotify(r).toString());
    }

然并卵,估计他们也不会用代码来调

我还是用工具,直接考报文来的实在一点

要用post,get是调不到滴

返回值


    
        
            
                201310281653151111945
                0
            
        
    

你可能感兴趣的:(cxf)