请教banq大哥:一个j2ee web service问题,困扰很久了

xuechen0721 06-01-06

我在https://uddi.ibm.com注册了一个uddi测试账户
以下是一段我编写的代码(参考的),意在尝试在账户中添加一个组织Chengguang
import javax.xml.registry.Connection;
import javax.xml.registry.ConnectionFactory;
import javax.xml.registry.RegistryService;
import javax.xml.registry.BusinessLifeCycleManager;
import javax.xml.registry.JAXRException;
import javax.xml.registry.JAXRResponse;
import javax.xml.registry.BulkResponse;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.InternationalString;
import java.net.PasswordAuthentication;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;

public class uddiRegistry {
public static void main(String[] args) throws JAXRException {
String companyName = "ChengGuang"; //添加的组织
String username = "xc81_2005@yahoo.com.cn";
String password = "05107300684";

Connection connection = connectionToRegistry(username,password);

//Access the RegistryService objects;
RegistryService registry = connection.getRegistryService();
BusinessLifeCycleManager lifeCycleMngr = registry.getBusinessLifeCycleManager();

//create an organization object and assign it a name;
Organization myOrganization = lifeCycleMngr.createOrganization(companyName);

//save the organization to the uddi directory;
Set organizationSet = new HashSet();
organizationSet.add(myOrganization);
BulkResponse response = lifeCycleMngr.saveOrganizations(organizationSet);

doException(response);


connection.close();
}

public static Connection connectionToRegistry(String username,String password) throws JAXRException {
javax.xml.registry.ConnectionFactory factory = javax.xml.registry.ConnectionFactory.newInstance();

Properties props = new Properties();
props.setProperty("javax.xml.registry.LifeCycleManagerURL",
"http://uddi.ibm.com/testregistry/publishapi");
props.setProperty("javax.xml.registry.queryManagerURL",
"http://uddi.ibm.com/testregistry/inquiryapi");
props.setProperty("javax.xml.registry.security.authenticationMethod",
"UDDI_GET_AUTHTOKEN");

factory.setProperties(props);

Connection connection = factory.createConnection();

PasswordAuthentication credential = new PasswordAuthentication(username,password.toCharArray());
Set credentials = new HashSet();
credentials.add(credential);
connection.setCredentials(credentials);

return connection;
}

public static void doException(BulkResponse rspns) throws JAXRException {
if(rspns.getStatus() == JAXRResponse.STATUS_SUCCESS) {
System.out.println("No problems reported!");
}else {
Iterator exceptions = rspns.getExceptions().iterator();
while(exceptions.hasNext()) {
Exception je = (Exception)exceptions.next();
System.out.println("- - - Exception - - -");
je.printStackTrace();
System.out.println("******************");
}
}
}
}

相关的类库(jaxr类库:jaxr-api.jar、jaxr-apisrc.jar)都已导入到环境变量中。
程序编译没有出现任何错误,而在运行时出现以下报错:

请问banq大哥,这是什么问题啊?研究了很久没弄明白,望赐教!谢谢

banq
2006-01-09 15:39

连接问题,从网络和安全方面考虑

xuechen0721
2006-01-09 20:03

能说的详细一点嘛?
我现在不知道怎样修改程序。我根本不清楚问题具体出在哪里?