我试图通过webservice(SOAP)
调用方法我使用JAX-WS生成了Web服务客户端。
我只能通过传输级安全性访问Web服务。
我收到错误:
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);
}
}
当我在类中调用此方法时,我得到了execption:'DummySubsForNetwork_Service'
@WebEndpoint(name = "DummySubsForNetworkSOAP")
public DummySubsForNetwork getDummySubsForNetworkSOAP()
{
return super.getPort(new QName("http://www.example.org/DummySubsForNetwork/",
"DummySubsForNetworkSOAP"), DummySubsForNetwork.class);
}
感谢, 射线。
答案 0 :(得分:0)