demo运行时报错,单步调试时不报错,这是为啥啊,求解!
程序代码:
package com.aisino.cxf; import import org.import com.aisino.cxf.*; public class TestCxf_kj { public static void main(String[] args) { try { //读取内层data报文 String xml = FileUtils.readFileToString(new File("D:\\Desktop\\uu.txt"), "gbk"); String resp=Commom.sendRequest(xml, Commom.FPKJCODE); int begin =resp.indexOf("<returnCode>"); int end =resp.indexOf("</returnCode>"); String content=resp.substring(begin+"<returnCode>".length(), end); int begin1 =resp.indexOf("<returnMessage>"); int end1 =resp.indexOf("</returnMessage>"); String content1=resp.substring(begin1+"<returnMessage>".length(), end1); if(content.equals("0000")) { System.out.println(resp); System.out.println(Base64Helper.decode(content1)); }else { System.out.println(resp); System.out.println(Base64Helper.decode(content1)); } } catch (Exception e) { e.printStackTrace(); } } }
程序代码:
package com.aisino.cxf; import import javax.xml.namespace.QName; import org.import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.apache.cxf.service.model.BindingInfo; import org.apache.cxf.service.model.BindingOperationInfo; import com.CaConstant; import com.aisino.PKCS7; public class Commom { public final static String FPKJCODE="ECXML.FPKJ.BC.E_INV"; //开具 public final static String FPXZCODE="ECXML.FPXZ.CX.E_INV"; //下载 public final static String FPQZCODE="ECXML.FPQZ.BC.E.INV"; //签章 public final static String FPTSCODE="ECXML.FPKJJG.TS.E_INV"; //推送 public final static String FPCXCODE="ECXML.FPCX.CX.E_INV"; //查询 public static String sendRequest(String xml,String interfaceCode) throws Exception{ //CA加密 final String trustsBytes = CaConstant.getProperty("PUBLIC_TRUSTS"); String decryptPFXBytes = CaConstant.getProperty("CLIENT_DECRYPTPFX"); String decryptPFXKey = CaConstant.getProperty("CLIENT_DECRYPTPFX_KEY"); final PKCS7 pkcs7Client = new PKCS7(FileUtils.readFileToByteArray(new File(trustsBytes)), FileUtils.readFileToByteArray(new File(decryptPFXBytes)), decryptPFXKey); final byte[] encodeData = pkcs7Client.pkcs7Encrypt(xml, FileUtils.readFileToByteArray(new File(CaConstant.getProperty("PLATFORM_DECRYPTCER")))); //base64加密 final byte[] base64Date = Base64Helper.encode(encodeData); String aa= new String(base64Date); // String aa=new String(Base64Helper.encode(xml)); String s = "SJLY" + (char)2 + "09" + (char)3 + "FPLX" + (char)2 + "1"; String globle = "<?xml version='1.0' encoding='utf-8' ?>"+ "<interface xmlns='' xmlns:xsi='http://www.' xsi:schemaLocation='http://www.chinatax.' version='DZFP1.0' >"+ "<globalInfo>"+ "<terminalCode>0</terminalCode>"+ "<appId>ZZS_PT_DZFP</appId>"+ "<version>2</version>"+ "<interfaceCode>"+interfaceCode+"</interfaceCode>"+ "<requestCode>17109066</requestCode>"+ "<requestTime>2016-06-29 10:30:42 968</requestTime>"+ "<responseCode>144</responseCode>"+ "<dataExchangeId>1710906620160807eXl4EymmJ</dataExchangeId>"+ "<userName>17109066</userName>"+ "<passWord>0981202688M0E0Rjk2ODU1MTlENEE2Mg==</passWord>"+ "<taxpayerId>110101TRDX8RQU1</taxpayerId>"+ "<authorizationCode>11RDX8RQU1</authorizationCode>"+ "</globalInfo>"+ "<returnStateInfo>"+ "<returnCode />"+ "<returnMessage />"+ "</returnStateInfo>"+ "<Data>"+ "<dataDescription>"+ " <zipCode>0</zipCode>"+ "<encryptCode>2</encryptCode>"+ "<codeType>0</codeType>"+ "</dataDescription>"+ "<content>" +aa+ "</content>"+ "</Data>"+ "</interface>"; // globle=xml; // System.out.println(globle); //http://ei-test.:20080/51TransferServicePro_zzs/webservice/eInvWS?wsdl //http://ei-test.:20080/51TransferServiceUpPro/webservice/eInvWS?wsdl // String url = "http://ei-test.:28888/fpqz/webservice/eInvWS?wsdl"; String url = "http://ei-test.// String url = "http://ei-test.:28888/fpqz/webservice/eInvWS?wsdl"; // String url = "http://192.168.15.125:8080/zzs_proxy/webservice/eInvWS?wsdl"; String operation = "eiInterface"; // String namespace = "http://ws."; JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); Client client = factory.createClient(url); // QName opName = new QName(namespace, operation); // 不硬编码namespace Endpoint endpoint = client.getEndpoint(); QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operation); BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding(); if (bindingInfo.getOperation(opName) == null) { for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) { if (operation.equals(operationInfo.getName().getLocalPart())) { opName = operationInfo.getName(); break; } } } // System.out.println(globle); Object[] res = client.invoke(opName, globle); System.out.println(res[0].toString()); return res[0].toString(); } }
程序代码:
2016-9-28 15:34:09 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 警告: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: Socket Closed at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:160) at org.apache.cxf.(DataWriterImpl.java:169) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:105) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:478) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:308) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:260) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:280) at com.aisino.(Commom.java:97) at com.aisino.cxf.TestCxf_kj.main(TestCxf_kj.java:15) Caused by: javax.xml.bind.MarshalException - with linked exception: [ Socket Closed] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:445) at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:139) ... 10 more Caused by: Socket Closed at (PlainSocketImpl.java:286) at (Socket.java:1032) at (HttpClient.java:356) at (HttpClient.java:273) at (HttpClient.java:310) at (HttpURLConnection.java:987) at (HttpURLConnection.java:923) at (HttpURLConnection.java:841) at (HttpURLConnection.java:1031) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1934) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1889) at org.apache.(AbstractWrappedOutputStream.java:42) at org.apache.(AbstractThresholdOutputStream.java:89) at org.apache.(AbstractThresholdOutputStream.java:63) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:412) at com.sun.xml.bind.v2.runtime.output.Encoded.write(Encoded.java:167) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.doText(UTF8XmlOutput.java:323) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:305) at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:328) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031) at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256) at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:130) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:361) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323) ... 14 more org.apache.cxf.interceptor.Fault: Marshalling Error: Socket Closed at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:160) at org.apache.cxf.(DataWriterImpl.java:169) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:105) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:478) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:308) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:260) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:280) at com.aisino.(Commom.java:97) at com.aisino.cxf.TestCxf_kj.main(TestCxf_kj.java:15) Caused by: javax.xml.bind.MarshalException - with linked exception: [ Socket Closed] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:445) at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:139) ... 10 more Caused by: Socket Closed at (PlainSocketImpl.java:286) at (Socket.java:1032) at (HttpClient.java:356) at (HttpClient.java:273) at (HttpClient.java:310) at (HttpURLConnection.java:987) at (HttpURLConnection.java:923) at (HttpURLConnection.java:841) at (HttpURLConnection.java:1031) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1934) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1889) at org.apache.(AbstractWrappedOutputStream.java:42) at org.apache.(AbstractThresholdOutputStream.java:89) at org.apache.(AbstractThresholdOutputStream.java:63) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:412) at com.sun.xml.bind.v2.runtime.output.Encoded.write(Encoded.java:167) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.doText(UTF8XmlOutput.java:323) at com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:305) at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:328) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031) at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256) at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:130) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:361) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323) ... 14 more
[此贴子已经被作者于2016-9-28 15:56编辑过]