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); } }
java_webservice调用_json转化
最新推荐文章于 2021-09-01 17:56:30 发布