Dear All
I have generated Client code against WSDL document using SoapUI tool. I have Sample Request XML packet as well. When I run Sample XML request packet (includes Header Authentication and Body) It give me output. But when I run Client code in
Java it is not authenticating and giving me error.
"Service request refused, client had none of the required roles".
I am pasting XML Request Packet and Client code against that as well. I am using JAX-WS.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.subscriberservices.sandvine.com">
<soapenv:Header xmlns:svsec="http://services.sandvine.com">
<svsec:username>****</svsec:username>
<svsec:password>*******</svsec:password>
</soapenv:Header>
<soapenv:Body>
<ws:LookupSubscriberRequest>
<Debug>false</Debug>
<SubscriberKey>
<SubscriberRealmKey>
<Name>DEFAULT</Name>
</SubscriberRealmKey>
<Name>*********</Name>
</SubscriberKey>
<!--Optional:-->
<ResponseGroups>
<ResponseGroup>Subscriber.CurrentIpAssignments</ResponseGroup>
</ResponseGroups>
</ws:LookupSubscriberRequest>
</soapenv:Body>
</soapenv:Envelope>
HelloClient.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ptcl.soap;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
public class HelloClient {
public static void main(
String[] args) {
SubscriberServices_Service service = null;
try {
// Creamos el servicio con el WSDL
URL wsdlLocation = new URL("http://x.x.x.x:xxx/SubscriberServices/SubscriberServices?wsdl");
String targetNamespace = "http://ws.subscriberservices.sandvine.com/";
String name = "SubscriberServices";
service = new SubscriberServices_Service(wsdlLocation, new QName(targetNamespace, name));
SubscriberServices subscriberServices = service.getSubscriberServicesPort();
// AƱadimos capacidades de seguridad a la llamada
BindingProvider provider = (BindingProvider) subscriberServices;
provider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "******");
provider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "******");
System.out.println(subscriberServices);
com.ptcl.soap.LookupSubscriberRequest request_usman = new com.ptcl.soap.LookupSubscriberRequest();
request_usman.setDebug(true);
// System.out.println(request_usman.getResponseGroups().getResponseGroup());
SubscriberKey sk = new SubscriberKey();
SubscriberRealmKey subscriberRealmKey = new SubscriberRealmKey();
// request_usman.setResponseGroups();
subscriberRealmKey.setName("DEFAULT");
sk.setSubscriberRealmKey(subscriberRealmKey);
sk.setName("********");
request_usman.setSubscriberKey(sk);
try {
System.out.println(subscriberServices.lookupSubscriber(request_usman).getErrors().getError().get(0).getMessage());
} catch (WsValidationException_Exception ex) {
Logger.getLogger(TestClient.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
Please help me in resolving this issue.