java访问webservice报错:
直接贴代码:
访问的时候还需要进行域验证:
代码:
public class DefaultAuthen extends Authenticator{
private static String username = "xxxxxx";
private static String domain = "xxxxx.com";
private static String password = "xxxxx";
public PasswordAuthentication getPasswordAuthentication() {
String usernamewithdomain = domain + "\\" + username;
return (new PasswordAuthentication(usernamewithdomain, password.toCharArray()));
}
}
public static void main(String[] args) throws Exception {
//验证
Authenticator.setDefault(new DefaultAuthen());
ListsSoap list = new Lists().getListsSoap();
GetListItems.Query query = new GetListItems.Query();
GetListItems.ViewFields vf = new GetListItems.ViewFields();
GetListItems.QueryOptions qo = new GetListItems.QueryOptions();
// 增加查询条件
Node elementOptions = generateXmlNode("");
//System.out.println(elementOptions.getAttributes().getNamedItem("Scope"));
//GetListItems.QueryOptions queryOptions = new GetListItems.QueryOptions();
qo.getContent().add(elementOptions);
//ListsSoap port = new Lists().getListsSoap();
///System.out.println(port.getList("中粮通讯录").getContent().get(0).toString());
//调用
GetListItemsResult listItems = list.getListItems("中粮通讯录", null, query,vf, Integer.MAX_VALUE+"", qo, null);
System.out.println(listItems.getContent().size());
}
生成查询条件:
public static Node generateXmlNode(String sXML)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
DocumentBuilder builder = factory.newDocumentBuilder();
Document documentOptions = builder.parse(new InputSource(new StringReader(sXML)));
Node elementOptions = documentOptions.getDocumentElement();
return elementOptions;
}
错误信息:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: 引发类型为“Microsoft.SharePoint.SoapServer.SoapServerException”的异常。
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at $Proxy30.getListItems(Unknown Source)
at com.euc.cofco.client.CallService.main(CallService.java:50)
网上找了一堆资料,暂时怀疑是命名空间的错误和不合法的类型转换;有人遇到过吗?
如果在浏览器里面直接输入wsdl地址,需要输入用户名和密码.....
求大婶解答