• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Issue in authenticating using SOAP Client

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic