我试图通过https protocal调用soap webservice。
我有wsdl并使用Apache CXF生成类,版本:3.0.5
当我在soapui中发布请求时,我从服务器
获得成功响应但是当从Java客户端调用同一个错误时:javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog
以下是java代码
package com.cts.pepsi.util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.DocumentDetails;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService_Service;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.EssJob;
import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ObjectFactory;
public class SoapClient {
private static final Logger log = LoggerFactory.getLogger(SoapClient.class);
private String username = "username";
private String password = "password";
static ErpIntegrationService erpIntegrationService;
static long value = 0;
public static void main(String[] args) {
log.info("START : Invoking service");
System.out.println("done");
try {
String documentAccount = null;
String documentTitle = null;
String fileName = null;
String interfaceDetails = null;
String jobName = null;
String jobParams = null;
EssJob essJob = new EssJob();
List<EssJob> jobList = new ArrayList<EssJob>();
ObjectFactory erpobjfac = new ObjectFactory();
documentAccount = "abc$/xyz$/take$";
documentTitle = "ekat throw bill";
fileName = "abcd.zip";
interfaceDetails = "2";
jobName = "/pqr/stu/ddd/fdg/qwe/tyu/poi,lkj";
jobParams = "090900909090909090909,andis,2016/05/17,,,,,,,,,,,,,,,,,,,,Y,null";
essJob.setJobName(erpobjfac.createEssJobJobName(jobName));
essJob.setParameterList(erpobjfac.createEssJobParameterList(jobParams));
jobList.add(essJob);
System.out.println("iiiii ");
StringBuffer encodedContent = new StringBuffer();
encodedContent.append("encoded content");//here Base64 encoded data is appended
//DocumentDetails
DocumentDetails docDtls = new DocumentDetails();
docDtls.setDocumentAccount(erpobjfac.createDocumentDetailsDocumentAccount(documentAccount));
docDtls.setContentType(erpobjfac.createDocumentDetailsContentType("zip"));
docDtls.setDocumentTitle(erpobjfac.createDocumentDetailsDocumentTitle(documentTitle));
docDtls.setFileName(fileName);
docDtls.setDocumentSecurityGroup(erpobjfac.createDocumentDetailsDocumentSecurityGroup("FAFtakeExcellent"));
docDtls.setContent(encodedContent.toString().getBytes());
//NotificationCode
String notificationCode = "50";
//CallBackURL
String callbackURL = "http://somecallbackserver.domain.com/mycallback";
new SoapClient().authenticate();
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ErpIntegrationService.class);
//factory.setAddress("https://eeln-test.fin.us2.oraclecloud.com:443/publicFinancialCommonErpIntegration/ErpIntegrationService");
factory.setAddress("http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/loadAndImportData");
factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
//ErpIntegrationService erpIntServiceSoap = (ErpIntegrationService) factory.create();
erpIntegrationService = (ErpIntegrationService) factory.create();
value = erpIntegrationService.loadAndImportData(docDtls, jobList, interfaceDetails, notificationCode, callbackURL);
System.out.println("value is not :- "+value);
}
catch (Exception e) {
log.error("An exception occurred, exiting", e);
}
}
public <K> void authenticate() {
log.info("Entering authenticate ");
try {
ErpIntegrationService_Service erpIntgService_Service = new ErpIntegrationService_Service();
this.erpIntegrationService = erpIntgService_Service.getErpIntegrationServiceSoapHttpPort();
Map requestCredentails = ((BindingProvider) this.erpIntegrationService).getRequestContext();
requestCredentails.put("javax.xml.ws.security.auth.username", this.username);
requestCredentails.put("javax.xml.ws.security.auth.password", this.password);
log.info("Exiting authenticate ");
} catch (Exception exception) {
log.info("Error in authenticate " + exception.getMessage());
}
}
}
下面的javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
at com.sun.proxy.$Proxy52.loadAndImportData(Unknown Source)
at com.cts.pepsi.util.SoapClient.main(SoapClient.java:109)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:685)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1154)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:165)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:66)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:802)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1645)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1533)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1336)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:652)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:138)
... 2 more
我从日志中获取了soap请求并从SOAP ui发布,它工作正常。
我试图从Java客户端调用wsdl中存在的所有操作,并重复相同的错误
下面的是wsdl政策
<wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="ErpIntegrationServiceSoapHttpPort_Input_Policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:EncryptedParts>
</wsp:All>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:EncryptedParts>
</wsp:All>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:EncryptedParts>
</wsp:All>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
请求您帮助我在java代码中犯错的地方,谢谢