java_webservice调用_json转化

package com.fybj365.modules.dataupload.test;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fybj365.modules.dataupload.client.jiangsu.Mchis;
import com.fybj365.modules.dataupload.client.jiangsu.MchisPortType;
import com.fybj365.modules.dataupload.client.jiangsu.ObjectFactory;
import com.fybj365.modules.dataupload.entity.WomanMain;
import net.sf.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2019-08-21.
 */
public class Test {
    public static void main(String[] args) throws MalformedURLException, JsonProcessingException {
        String url = "http://localhost:8888/test-controller/services/Test?wsdl";
        URL wsdlLocation = new URL(url);
        Test objF = new Test(wsdlLocation);
        TestPortType testPortType = objF.getTestHttpSoap13Endpoint();

        /**
         * 获取token
         */
        /*String st = testPortType.login("admin","123456");
        JSONObject jSONObject = JSONObject.fromObject(st);
        System.out.println("返回jSONObject" + jSONObject);
        Map<String,Object> resuletMap = (Map) jSONObject;
        String result = (String) resuletMap.get("result");
        String message = (String) resuletMap.get("message");
        Map<String,Object> dataMap = (Map) resuletMap.get("data");

        String token = (String) dataMap.get("token");
        System.out.println("返回result:" + result);
        System.out.println("返回message:" + message);
        System.out.println("返回dataMap:" + dataMap);
        System.out.println("返回token:" + token);*/

        /**
         * 上传WomanMain
         * 测试
         */
        WomanMain womanMain = new WomanMain();
        womanMain.setAddrCode("11111");
        womanMain.setAbo("2222");
        womanMain.setAge("33");
        JSON jsonStr = (JSON) JSON.toJSON(womanMain);
        System.out.println("WomanMain:" + jsonStr);

        Map<String,Object > data = new HashMap<String,Object>();
        String jsondata;
        data.put("source", "womanMain");
        data.put("remark", "test建卡");
        data.put("operate", "save");
        data.put("data", jsonStr);
        jsondata = JSON.toJSONString(data);
        System.out.println("生成的jsondata:" + jsondata);
        String result = testPortType.saveData("8888888888",jsondata);
        System.out.println("result:" + result);
    }


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值