我想使用apache cxf make client(java(请求WebService。
WebService:
https://extenavigator.ukho.gov.uk/serviceb2b/submitukhoordering.svc https://extenavigator.ukho.gov.uk/serviceb2b/submitukhoordering.svc?singlewsdl
我使用wsdl2java生成Java代码,
它不起作用:
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
proxyFactory.setServiceClass(IOrderingService.class);
proxyFactory.setAddress("https://extenavigator.ukho.gov.uk/serviceB2B/submitUKHOOrdering.svc");
proxyFactory.setUsername(USERNAME);
proxyFactory.setPassword(PASSWORD);
proxyFactory.setBindingId("http://www.w3.org/2003/05/soap/bindings/HTTP/");
IOrderingService client = (IOrderingService) proxyFactory.create();
System.out.println("submit order...");
SubmitOrderResponse submitOrderResponse = client.submitOrder(WebService.makeSubmitOrderRequest());
System.out.println("submit order response...");
Integer orderId = submitOrderResponse.getOrderId();
System.out.println("orderId:" + orderId);
submitOrderResponse.getOrderStatus().getValue().getOrderItemStatus().forEach(item -> {
System.out.println("item.getProduct:" + item.getProduct());
System.out.println("item.getStatus:" + item.getStatus());
});
System.out.println("AccountId:" + submitOrderResponse.getAccountId());
投掷
java.net.sockettimeoutexception:读取时间
我尝试使C#客户端请求服务,
它正在工作!
uk.OrderingServiceClient client = new uk.OrderingServiceClient();
if (client.ClientCredentials != null)
{
client.ClientCredentials.UserName.UserName = "XXXXXX";
client.ClientCredentials.UserName.Password = "XXXXXX";
}
client.Endpoint.Address = new EndpointAddress("https://extenavigator.ukho.gov.uk/serviceB2B/submitUKHOOrdering.svc");
var response = client.SubmitOrder(new SubmitOrderRequest()
{
Order = new Order()
{
DistId = 2960,
LicenceId = 45039,
DeliveryMethod = DeliveryMethod.Both,
OrderItems = new OrderItem[]{
new OrderItem()
{
ProductId = "AR201130",
ProductPeriod = 9,
ProductType = ProductType.AVCSCharts
}
}
},
RequestId = Guid.NewGuid().ToString()
});
任何解决方案(java客户端(?
此代码正在工作:
OrderingService service = new OrderingService();
IOrderingService port = service.getWSHttpBindingIOrderingService();
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put("ws-security.username", USERNAME);
bp.getRequestContext().put("ws-security.password", PASSWORD);
System.out.println("submit order...");
SubmitOrderResponse submitOrderResponse = port.submitOrder(WebService.makeSubmitOrderRequest());
System.out.println("submit order response...");
Integer orderId = submitOrderResponse.getOrderId();
System.out.println("orderId:" + orderId);
submitOrderResponse.getOrderStatus().getValue().getOrderItemStatus().forEach(item -> {
System.out.println("item.getProduct:" + item.getProduct());
System.out.println("item.getStatus:" + item.getStatus());
});
System.out.println("AccountId:" + submitOrderResponse.getAccountId());