[reg+disp32]
当我使用SOAPUI响应正确时,但是当我使用此Java代码时,响应为“ s 响应长度只有1个字符 [s:Fault:null]
xml文件就是这样
public class RestRequest {
public Iteam getInformationAboutObject(String nip, String authorizationToken) throws SOAPException, IOException {
String strMsg = "";
final String BASE_URL = "https://datastore.ceidg.gov.pl/CEIDG.DataStore/services/DataStoreProvider201901.svc";
StringEntity xmlEntity = null;
try {
StringBuilder sb = new StringBuilder("");
BufferedReader in = new BufferedReader(new FileReader("C://Users/user/Desktop/SoapMessage.xml"));
String nextLine = "";
while((nextLine = in.readLine()) != null){
sb.append(nextLine + "\n");
}
strMsg = sb.toString();
System.out.println(strMsg);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
XmlMapper xmlMapper = new XmlMapper();
Iteam iteam = null;
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage smsg = mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(strMsg.getBytes()));
SOAPPart sp = smsg.getSOAPPart();
SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();
SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage response = conn.call(smsg, "https://datastore.ceidg.gov.pl/CEIDG.DataStore/services/DataStoreProvider201901.svc");
String message = response.getSOAPBody().getPrefix();
System.out.println(message);
if((message != null || !message.equals("")) && message.length()>3) {
InformacjaOWpisie informacjaOWpisie = xmlMapper.readValue(message, InformacjaOWpisie.class);
iteam = new Iteam(informacjaOWpisie);
}
else{
System.out.println("Response length have only "+message.length()+" chars");
}
conn.close();
SOAPPart spR = response.getSOAPPart();
SOAPEnvelope seR = spR.getEnvelope();
SOAPBody sbR = seR.getBody();
Iterator itR = sbR.getChildElements();
while (itR.hasNext()) {
System.out.println(itR.next().toString());
// SOAPBodyElement bodyElement = (SOAPBodyElement) itR.next();
// Iterator it2 = bodyElement.getChildElements();
// while (it2.hasNext()) {
// SOAPElement element2 = (SOAPElement) it2.next();
// System.out.println("X -> "+element2.getValue());
// }
}
return new Iteam();
}
}
我该如何解决我的问题? 我已经尝试过使用来自Apache的HTTPClient,但这不起作用。
https://datastore.ceidg.gov.pl/CEIDG.DataStore/Styles/Regulations/API_Datastore_20190314.pdf