我正在尝试在Java程序中调用invoke子服务。在下面的程序中编写以调用服务。但是作为回应,我得到了500个错误代码。 有什么我想念的吗?任何人都可以查看下面的代码吗?
通过SOAP UI,我可以获得响应。但是,通过Java程序,该服务没有被调用。不确定,通过SOAP UI和Java程序建立连接之间有什么区别。
package com.test;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.RequestWrapper;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
public class test {
private static final String TEST_SOURCE = "test_source";
private static final String TEST_REGION = "test_region";
private static final String TEST_TID = "test_tid";
private static final String TEST_IPADDRESS = "test_ipaddress";
private static final String TEST_APPID = "test_appid";
private static final String CLIENT_SECRET = "client_secret";
private static final String CLIENT_ID = "client_id";
private static final String APPLICATION = "ADE";
private static final String MULE_URL = "https://apis-ait.xxx.com/nonBilling/v1/eProxy/services/customerinform";
public static void main(String[] args) {
try {
javax.net.ssl.SSLSocketFactory WAS_SSLFactory = (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory
.getDefault();
org.apache.http.conn.ssl.SSLSocketFactory socketFactory = new org.apache.http.conn.ssl.SSLSocketFactory(
WAS_SSLFactory, org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
org.apache.http.conn.scheme.Scheme sch = new org.apache.http.conn.scheme.Scheme("https", 443,
socketFactory);
HttpParams httpParams = new BasicHttpParams();
DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
HttpPost httpPost = new HttpPost(MULE_URL);
httpPost.setHeader(CLIENT_ID, "213xxxxx");
httpPost.setHeader(CLIENT_SECRET, "282Dxxxxxxx");
httpPost.setHeader(TEST_TID, String.valueOf(java.util.UUID.randomUUID()));
httpPost.setHeader(TEST_APPID, APPLICATION);
httpPost.setHeader(TEST_SOURCE, APPLICATION);
httpPost.setHeader(TEST_REGION, "MA11");
httpPost.setHeader(TEST_IPADDRESS, "x.x.x.x");
String soapXML = "<retrieveCustomers><systemName>ADE</systemName></requestHeader><customerGroupAgentUserId>guzm254</customerGroupAgentUserId><customerSearchRequest><agreementReferenceSearchIndicatorAsString>Y</agreementReferenceSearchIndicatorAsString><billingAccountReferenceSearchIndicatorAsString>N</billingAccountReferenceSearchIndicatorAsString><searchCategoryTypeAsString>A_AOR</searchCategoryTypeAsString><customerSearchCriteria ><agentReference>880417</agentReference><agreementReference>189857278</agreementReference><alternateCustomerReference>635671214</alternateCustomerReference></customerSearchCriteria></customerSearchRequest></retrieveCustomers>";
StringEntity stringEntity = new StringEntity(soapXML);
httpPost.setEntity(stringEntity);
httpPost.setHeader("Content-type", "application/xml");
httpPost.setHeader("SOAPAction", "");
RequestWrapper requestWrapper = new RequestWrapper(httpPost);
HttpResponse response = httpClient.execute(requestWrapper);
System.out.println("StatusCode >> " + response.getStatusLine().getStatusCode());
System.out.println("sendToECMSService(), response = " + response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
获取500个错误代码。它应该生成成功代码。