问题描述
- java cxf webservices 动态调用sap的一个服务地址,地址是带用户名和密码的权限。
-
import java.net.URL;import javax.xml.namespace.QName;
import org.apache.cxf.configuration.security.AuthorizationPolicy;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;public class testwebservices {
public static void main(String[] args) { String url = "http://xxx?sap-client=100";//地址为一个sap的服务,带有用户名和密码权限。 JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory .newInstance(); //此处应该增加什么代码以便通过用户名密码权限,现在没设置回报401访问不通过 Client client = factory.createClient(url); try { Object[] d = { "test" }; QName opName = new QName("sdfdf", "sayHello"); Object[] obj = client.invoke(opName, d); System.out.println("resp:" + obj[0]); } catch (Exception e) { e.printStackTrace(); } }
}
解决方案
http://lib.csdn.net/expert/cList?knowledge_id=248你的答案
时间: 2024-12-01 20:02:02