Я пытаюсь вызвать метод через веб-сервис (SOAP)
Я сгенерировал клиент Web-сервиса с JAX-WS.
Я могу получить доступ к веб-сервису только с безопасностью транспортного уровня.
Я получаю ошибку:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://10.99.36.26:8001/DummySubsForNetwork?wsdl. It failed with:
Server returned HTTP response code: 401 for URL: http://10.99.36.26:8001/DummySubsForNetwork?wsdl.
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:263)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:226)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:174)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.<init>(Unknown Source)
at com.mirs.sbn.esb.client.DummySubsForNetwork_Service.<init>(DummySubsForNetwork_Service.java:67)
at main.executeEsbRequest(main.java:167)
at main.testEsb(main.java:141)
at main.main(main.java:59)
это мой код:
Основной метод, который я выполняю:
private static DummySubsForNetwork executeEsbRequest()
{
DummySubsForNetwork_Service service = new DummySubsForNetwork_Service();
DummySubsForNetwork dummyPort = service.getDummySubsForNetworkSOAP();
Map<String, Object> rc = ((BindingProvider) dummyPort).getRequestContext();
rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://some.local.ip:8001/DummySubsForNetwork?wsdl");
rc.put(BindingProvider.USERNAME_PROPERTY, "csmuser");
rc.put(BindingProvider.PASSWORD_PROPERTY, "passw0rd");
return dummyPort;
}
Автоматически сгенерированный класс через JAX-WS:
@WebServiceClient(name = "DummySubsForNetwork", targetNamespace = "http://www.example.org/DummySubsForNetwork/", wsdlLocation = "http://some.local.ip:8001/DummySubsForNetwork?wsdl")
public class DummySubsForNetwork_Service extends Service
{
private final static URL DUMMYSUBSFORNETWORK_WSDL_LOCATION;
private final static Logger logger = Logger
.getLogger(com.mirs.sbn.esb.client.DummySubsForNetwork_Service.class.getName());
static
{
URL url = null;
try
{
URL baseUrl;
baseUrl = com.mirs.sbn.esb.client.DummySubsForNetwork_Service.class.getResource(".");
url = new URL(baseUrl, "http://some.local.ip:8001/DummySubsForNetwork?wsdl");
}
catch (MalformedURLException e)
{
logger
.warning("Failed to create URL for the wsdl Location: 'some.local.ip:8001/DummySubsForNetwork?wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
DUMMYSUBSFORNETWORK_WSDL_LOCATION = url;
}
public DummySubsForNetwork_Service(URL wsdlLocation, QName serviceName)
{
super(wsdlLocation, serviceName);
}
public DummySubsForNetwork_Service()
{
super(DUMMYSUBSFORNETWORK_WSDL_LOCATION, new QName(
"http://www.example.org/DummySubsForNetwork/", "DummySubsForNetwork"));
}
/**
*
* @return returns DummySubsForNetwork
*/
@WebEndpoint(name = "DummySubsForNetworkSOAP")
public DummySubsForNetwork getDummySubsForNetworkSOAP()
{
return super.getPort(new QName("http://www.example.org/DummySubsForNetwork/",
"DummySubsForNetworkSOAP"), DummySubsForNetwork.class);
}
}
Я получаю освобождение при вызове этого метода в классе: 'DummySubsForNetwork_Service'
@WebEndpoint(name = "DummySubsForNetworkSOAP")
public DummySubsForNetwork getDummySubsForNetworkSOAP()
{
return super.getPort(new QName("http://www.example.org/DummySubsForNetwork/",
"DummySubsForNetworkSOAP"), DummySubsForNetwork.class);
}
спасибо,
лучей.