php如何调用别人给的java接口
因为要用到对方一个查询接口, 对方java那边开发了此接口 请求参数通过xml文件发送 然后返回一个xml文件给我.
我试了用curl没有成功, 还有那个接口地址我直接在浏览器打开报错, 是他们的问题?
下面是对方的java请求例子
java测试用例:
public void testQueryPolicy() throws Exception{
HttpClient client = new HttpClient();//HttpClient Version: 3.0-rc3 //10.100.148.194
client.getState().setCredentials( new AuthScope("test.tpis.tpaic.com", 13180, AuthScope.ANY_REALM), new UsernamePasswordCredentials("avaiTest", "password"));
PostMethod get = new PostMethod("http://test.tpis.tpaic.com:13180/webservice/queryPolicy.do");
get.setDoAuthentication( true );
get.setRequestHeader("Content-Type", "textml;charset=GBK");
try {
String requestString = "<?xml version=\"1.0\" encoding=\"GBK\"?>"
+ "<plTpaic>"
+ "<plTpaicRequest>"
+ "<policyNo>21000000790150000003</policyNo>"
+ "<certNo>440183198604093426</certNo>"
+ "</plTpaicRequest>"
+ "</plTpaic>";
RequestEntity entity = new StringRequestEntity(requestString, "text/xml", "GBK");
get.setRequestEntity(entity);
client.executeMethod( get );
SAXBuilder sb = new SAXBuilder();
Document doc = null;
try {
doc = sb.build(new InputStreamReader(get.getResponseBodyAsStream(),"GBK"));
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Format format = Format.getPrettyFormat();
format.setEncoding("GBK");
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(format);
String xmlString = outputter.outputString(doc);
System.out.println(xmlString);
} catch (Exception e) {
e.printStackTrace();
}
}
求教 根据他这个 , php该如何请求.