Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HttpClientAndPostCheck {
- private StringBuilder stringBuilder;
- public HttpClientAndPostCheck() {
- }
- public static Document VerPIN(String xml) throws Exception
- {
- DocumentBuilderFactory doc = DocumentBuilderFactory.newInstance();
- DocumentBuilder blr = doc.newDocumentBuilder();
- InputSource inser = new InputSource(new StringReader(xml));
- return null;
- }
- public String runXML() {
- String resultat = "";
- stringBuilder = new StringBuilder();
- stringBuilder.append(String.format("<?xml version="1.0"
- encoding="UTF-8" ?>" +
- "<soapenv:Envelope
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:_0="http://test.org/ADInterface/1_0">" +
- "<soapenv:Header/>" +
- "<soapenv:Body>" +
- "<_0:queryData>" +
- " <_0:ModelCRUDRequest>" +
- " <_0:ModelCRUD> " +
- " <_0:serviceType>checkForPIN</_0:serviceType> " +
- " <_0:DataRow> " +
- " <_0:field column="UserPIN"> " +
- " <_0:val>0000</_0:val> " +
- " </_0:field> " +
- " <_0:field column="Phone"> " +
- " <_0:val>0015145542122</_0:val> " +
- " </_0:field> " +
- " </_0:DataRow> " +
- " </_0:ModelCRUD>" +
- " <_0:ADLoginRequest> " +
- " <_0:user>WebService</_0:user> " +
- " <_0:pass>WSTest3</_0:pass> " +
- " <_0:lang>en_US</_0:lang> " +
- " <_0:ClientID>1000000</_0:ClientID> " +
- " <_0:RoleID>1000035</_0:RoleID> " +
- " <_0:OrgID>1000000</_0:OrgID> " +
- " <_0:WarehouseID>1000000</_0:WarehouseID> " +
- " <_0:stage>0</_0:stage> " +
- " </_0:ADLoginRequest> " +
- " </_0:ModelCRUDRequest> " +
- " </_0:queryData> " +
- " </soapenv:Body> " +
- "</soapenv:Envelope>"));
- return resultat;
- }
- String xml= stringBuilder.toString();
- HttpPost httppost = new
- HttpPost("http://dev.testgob.com/ADInterface/services");
- HttpPost post = new
- HttpPost("http://de.testgob.com/ADInterface/services");
- AuthScope as = new AuthScope("de.testgob.com" , 452);
- CredentialsProvider provider=new BasicCredentialsProvider();
- UsernamePasswordCredentials txt = new
- UsernamePasswordCredentials("username", "password");
- **//the errors begin**
- provider.setCredentials(AuthScope.ANY, txt);
- HttpClient client = HttpClientBuilder.create()
- .setDefaultCredentialsProvider(provider)
- .Build();
- StringEntity entity;
- try {
- entity = new StringEntity(xml, StandardCharsets.UTF_8);
- httppost.setHeader("Content-Type","text/xml;Charset-UTF_8");
- httppost.setEntity(entity);
- HttpResponse response = client.execute(httppost);
- result = EntityUtils.toString(response.getEntity());
- return result;
- }
- catch(Exception e) {
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment