我试图用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.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
中的网络服务的测试用例(工作正常)
但是,在java
中,我使用wsimport
生成了一个客户端,并在SoapUI中测试了相同的大小写,因此我得到了上述异常。
Ps:webservice是使用C#开发的,例外是C#。
1 - 客户端java:
这是生成的sendInvoice()服务
/**
*
* @param sessionID
* @param alias
* @param invoice
* @return
* returns java.lang.Boolean
*/
@WebMethod(action = "http://tempuri.org/IPostBoxService/sendInvoice")
@WebResult(name = "sendInvoiceResult", targetNamespace = "http://tempuri.org/")
@RequestWrapper(localName = "sendInvoice", targetNamespace = "http://tempuri.org/", className = "org.tempuri.SendInvoice")
@ResponseWrapper(localName = "sendInvoiceResponse", targetNamespace = "http://tempuri.org/", className = "org.tempuri.SendInvoiceResponse")
public Boolean sendInvoice(
@WebParam(name = "invoice", targetNamespace = "http://tempuri.org/")
DocumentType invoice,
@WebParam(name = "alias", targetNamespace = "http://tempuri.org/")
String alias,
@WebParam(name = "sessionID", targetNamespace = "http://tempuri.org/")
String sessionID);
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)
}
是否有任何人有线索或提示,我应该从哪里开始搜索原因,我无法访问WebService,因此我无法对其进行调试。