WebService调用socket返回乱码,写死参数就不会
轻吻荔枝香 2016-12-06 04:14:22 在webservice中写死xml的值,那么就一切正常,如果通过调用webservice的时候写入值,断点跟踪的时候xml的值也是正常的,但是socket返回的信息就是乱码的,求助啊!
@Override
public String sendZhuanjie(String xml) {
ScoketClient sc = new ScoketClient();
//xml如果写死就不会有问题,如果换成传输过来的也显示正常但是 result就为乱码
String result = sc.openSocketClient("127.0.0.1",11777,xml);
System.out.println("返回信息" + result);//result
String resultXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>[result]</result>";
resultXML = resultXML.replace("[result]", result);
}
//前端调用webservice
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClient("http://localhost:8080/WEB/webservice/childWebService?wsdl");
Object[] objects=null;
try {
String xml = “”
objects = client.invoke("sendZhuanjie", xml);
System.out.println(objects[0].toString());
} catch (Exception e) {
e.printStackTrace();
}