Java 调用SOAP Web设备时出现SOAPFaultException
我试图用java客户端(wsimport)调用Web服务,当我调用时,总是会遇到以下异常:Java 调用SOAP Web设备时出现SOAPFaultException,java,web-services,soap,wsimport,soapfault,Java,Web Services,Soap,Wsimport,Soapfault,我试图用java客户端(wsimport)调用Web服务,当我调用时,总是会遇到以下异常: javax.xml.ws.soap.SOAPFaultException: Object reference not set to an instance of an object. at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178) at com.sun.xml.i
javax.xml.ws.soap.SOAPFaultException: Object reference not set to an instance of an object.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at com.sun.proxy.$Proxy34.sendInvoice(Unknown Source)
at com.audaxis.compiere.osg.ws.ClientEInvoice.sendEInvoice(ClientEInvoice.java:124)
at com.audaxis.compiere.osg.ws.ClientEInvoice.callEInvoice(ClientEInvoice.java:203)
at com.audaxis.compiere.osg.util.test.main(test.java:50)
10
因此,这是SoapUI
中web服务的测试用例(工作正常)
但是,在java
中,我使用wsimport
生成了一个客户端,并在SoapUI中测试了相同的情况,因此我得到了上面的异常。
Ps:webservice是使用C语言开发的,但C语言是个例外
1-客户端java:
这是生成的sendInvoice()服务
2-呼叫服务
public class test {
public static void main(String[] args) throws Exception {
ObjectFactory factory = new ObjectFactory();
File xml = new File("/home/azb/Desktop/OSG2017000000368.xml");
String UUID = "f245c530-3387-40f3-8cc3-564892941764" ;
//Compress XML to ZIP (required by the web service)
String path = xml.getAbsoluteFile().toString();
path = path.substring(0, path.length() - 4);
File compressedXml = new File(path + ".zip");
File encodedCompressedXML = new File(path + ".txt");
zip(compressedXml, xml);
//enconding compressedXml into Base64
FileCodecBase64.encode(compressedXml.getAbsolutePath(), encodedCompressedXML.getAbsolutePath(), true);
GregorianCalendar c = new GregorianCalendar();
c.setTime(new java.util.Date());
XMLGregorianCalendar currentDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
Base64BinaryData data = new Base64BinaryData();
data.setContentType(factory.createBase64BinaryDataContentType("Base64"));
data.setValue(factory.createBase64BinaryDataValue(FileCodecBase64.getBase64EncodedData()));
DocumentType ublInvoice = new DocumentType();
ublInvoice.setBinaryData(factory.createBase64BinaryData(data));
ublInvoice.setFileName(factory.createElementTypeFileName(compressedXml.getAbsolutePath()));
ublInvoice.setHash(factory.createElementTypeHash("DB94F3527130713C8E997FB5B453A177"));
ublInvoice.setCurrentDate(currentDate);
ClientEInvoice client = new ClientEInvoice("user", "psw", "https://test1.diyalogo.com.tr/Webservice/PostBoxService.svc", UUID); //in constuctor we instance the stub = new PostBoxService(new URL(url));
stub.getPostBoxServiceEndpoint().sendInvoice(ublInvoice, UUID, sessionID)
}
是否有人有线索或提示,关于我应该从哪里开始搜索原因,我没有访问Web服务的权限,因此无法调试它。EInvoice的价值是什么?声明存根的位置是
stub
?在我看来,代码的某些部分丢失了…对不起,我犯了一个错误,它的publinvoice不是EInvoice,它现在被更正了,谢谢EInvoice
的价值是什么?声明存根的位置是stub
?在我看来,代码的某些部分丢失了…对不起,我犯了一个错误,它是publinvoice而不是EInvoice,它现在被更正了,谢谢
public class test {
public static void main(String[] args) throws Exception {
ObjectFactory factory = new ObjectFactory();
File xml = new File("/home/azb/Desktop/OSG2017000000368.xml");
String UUID = "f245c530-3387-40f3-8cc3-564892941764" ;
//Compress XML to ZIP (required by the web service)
String path = xml.getAbsoluteFile().toString();
path = path.substring(0, path.length() - 4);
File compressedXml = new File(path + ".zip");
File encodedCompressedXML = new File(path + ".txt");
zip(compressedXml, xml);
//enconding compressedXml into Base64
FileCodecBase64.encode(compressedXml.getAbsolutePath(), encodedCompressedXML.getAbsolutePath(), true);
GregorianCalendar c = new GregorianCalendar();
c.setTime(new java.util.Date());
XMLGregorianCalendar currentDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
Base64BinaryData data = new Base64BinaryData();
data.setContentType(factory.createBase64BinaryDataContentType("Base64"));
data.setValue(factory.createBase64BinaryDataValue(FileCodecBase64.getBase64EncodedData()));
DocumentType ublInvoice = new DocumentType();
ublInvoice.setBinaryData(factory.createBase64BinaryData(data));
ublInvoice.setFileName(factory.createElementTypeFileName(compressedXml.getAbsolutePath()));
ublInvoice.setHash(factory.createElementTypeHash("DB94F3527130713C8E997FB5B453A177"));
ublInvoice.setCurrentDate(currentDate);
ClientEInvoice client = new ClientEInvoice("user", "psw", "https://test1.diyalogo.com.tr/Webservice/PostBoxService.svc", UUID); //in constuctor we instance the stub = new PostBoxService(new URL(url));
stub.getPostBoxServiceEndpoint().sendInvoice(ublInvoice, UUID, sessionID)
}