I am very new to the ws-* support features. One of my customer gave a WSDL to
access their data. They are using Microsoft Identity Server for
authentication. I am using APACHE CXF library to develop this feature. I
read some document related to ws federation in CXF but I wasn't understand
the whole concept. I am posting my WSDL and client code and the error I am
getting. Can any one help me on this.?
Here the ws policy content from my WSDL
<wsp:Policy wsu:Id="WS2007FederationHttpBinding_IStoreService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken />
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256 />
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp />
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:IssuedToken
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<Issuer
xmlns="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<Address
xmlns="http://www.w3.org/2005/08/addressing">
https://slc.centershift.com/STS/issue/wstrust/mixed/username
</Address>
<Metadata
xmlns="http://www.w3.org/2005/08/addressing">
<Metadata
xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wsx:MetadataSection xmlns="">
<wsx:MetadataReference>
<Address
xmlns="http://www.w3.org/2005/08/addressing">https://slc.centershift.com/STS/issue/mex</Address>
</wsx:MetadataReference>
</wsx:MetadataSection>
</Metadata>
</Metadata>
</Issuer>
<sp:RequestSecurityTokenTemplate>
<trust:KeyType
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
</trust:KeyType>
<trust:CanonicalizationAlgorithm
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
<trust:EncryptionAlgorithm
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
</sp:RequestSecurityTokenTemplate>
<wsp:Policy>
<sp:RequireInternalReference />
</wsp:Policy>
</sp:IssuedToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
<sp:Wss11
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy />
</sp:Wss11>
<sp:Trust13
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:MustSupportIssuedTokens />
<sp:RequireClientEntropy />
<sp:RequireServerEntropy />
</wsp:Policy>
</sp:Trust13>
<wsaw:UsingAddressing />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
*Here is the service end-point:*
<wsdl:service name="StoreService">
<wsdl:port name="WS2007FederationHttpBinding_IStoreService"
binding="tns:WS2007FederationHttpBinding_IStoreService">
<soap12:address
location="https://slc.centershift.com/Store40/StoreService.svc" />
<wsa10:EndpointReference>
<wsa10:Address>
https://slc.centershift.com/Store40/StoreService.svc
</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
*Client Code:*
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.Executors;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.AddressingFeature;
import
com.reputation.r4e.integrator.centershift.handler.CenterShiftServiceConfigurator;
import
com.reputation.r4e.integrator.centershift.sws2.ArrayOfParameterValues;
import
com.reputation.r4e.integrator.centershift.sws2.GetDataViewResponse.GetDataViewResult;
import com.reputation.r4e.integrator.centershift.sws2.GetDataView_Request;
import com.reputation.r4e.integrator.centershift.sws2.IStoreService;
import com.reputation.r4e.integrator.centershift.sws2.ParameterValues;
import com.reputation.r4e.integrator.centershift.sws2.StoreService;
public class CentershiftSws2Client {
CenterShiftServiceConfigurator serviceConfigurator;
public IStoreService service;
/**
* Get the Test service instance for use. If the instance does not
create
* yet, create it.
*
* @return The service instance
*/
public IStoreService getService() {
if (service == null) {
service = createTestOperationManagerInstance();
}
return service;
}
/**
* Creates and returns the instance of the {@link TestOperationManager}
*
* @return instance of the {@link TestOperationManager}
*/
public IStoreService createTestOperationManagerInstance() {
StoreService service = new
StoreService(getWsdlLocation(StoreService.WSDL_LOCATION));
service.setExecutor(Executors.newCachedThreadPool());
IStoreService testOperationManagerSoap = service
.getWS2007FederationHttpBindingIStoreService(new
AddressingFeature(true));
getServiceConfigurator().configure(testOperationManagerSoap);
return testOperationManagerSoap;
}
/**
* Used to get the environment-specific location of the wsdl. If there
is no
* concept of an environment-specific location of the wsdl, then just
return
* the input codedWSDL
*/
public URL getWsdlLocation(URL codedWSDL) {
URL wsdlLocation = null;
try {
wsdlLocation = new
URL("https://slc.centershift.com/Store40/StoreService.svc?wsdl");
} catch (MalformedURLException mue) {
wsdlLocation = codedWSDL;
}
return wsdlLocation;
}
public CenterShiftServiceConfigurator getServiceConfigurator() {
return serviceConfigurator;
}
public void setServiceConfigurator(CenterShiftServiceConfigurator
centershiftServiceConfigurator) {
this.serviceConfigurator = centershiftServiceConfigurator;
}
public static void main(String[] args) {
CentershiftSws2Client testService = new CentershiftSws2Client();
CenterShiftServiceConfigurator serviceConfigurator = new
CenterShiftServiceConfigurator();
testService.setServiceConfigurator(serviceConfigurator);
IStoreService storeService = testService.getService();
((BindingProvider)
storeService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://slc.centershift.com/Store40/StoreService.svc");
((BindingProvider)
storeService).getResponseContext().put("ws-security.username.sct",
"USER_NAME");
((BindingProvider)
storeService).getResponseContext().put("ws-security.password.sct",
"PASSWORD");
GetDataView_Request dataView_Request = new GetDataView_Request();
dataView_Request.setOrgID("ORG_ID");
dataView_Request.setSiteID("SITE_ID");
dataView_Request.setViewName("VIEW_NAME");
ArrayOfParameterValues parameterValues = new
ArrayOfParameterValues();
ParameterValues paramters = new ParameterValues();
paramters.setFilterType(0);
paramters.setParameterName("start_date");
paramters.setParameterValue("2016-10-01T00:00:00.000-06:00");
parameterValues.getParameterValues().add(paramters);
dataView_Request.setParameters(parameterValues);
GetDataViewResult dataViewResult =
storeService.getDataView(dataView_Request);
List list = dataViewResult.getAny();
System.out.println(list.size());
}
}
StoreService Class:
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.1.7
* 2016-10-06T21:02:01.741+05:30
* Generated source version: 3.1.7
*
*/
@WebServiceClient(name = "StoreService",
wsdlLocation =
"https://slc.centershift.com/Store40/StoreService.svc?wsdl",
targetNamespace = "http://tempuri.org/")
public class StoreService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://tempuri.org/",
"StoreService");
public final static QName WS2007FederationHttpBindingIStoreService = new
QName("http://tempuri.org/", "WS2007FederationHttpBinding_IStoreService");
static {
URL url = null;
try {
url = new
URL("https://slc.centershift.com/Store40/StoreService.svc?wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(StoreService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}",
"https://slc.centershift.com/Store40/StoreService.svc?wsdl");
}
WSDL_LOCATION = url;
}
public StoreService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public StoreService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public StoreService() {
super(WSDL_LOCATION, SERVICE);
}
public StoreService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public StoreService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public StoreService(URL wsdlLocation, QName serviceName,
WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns IStoreService
*/
@WebEndpoint(name = "WS2007FederationHttpBinding_IStoreService")
public IStoreService getWS2007FederationHttpBindingIStoreService() {
return super.getPort(WS2007FederationHttpBindingIStoreService,
IStoreService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on
the proxy. Supported features not in the <code>features</code> parameter
will have their default values.
* @return
* returns IStoreService
*/
@WebEndpoint(name = "WS2007FederationHttpBinding_IStoreService")
public IStoreService
getWS2007FederationHttpBindingIStoreService(WebServiceFeature... features) {
return super.getPort(WS2007FederationHttpBindingIStoreService,
IStoreService.class, features);
}
}
*Exception: *
[WARN ][Wsdl11AttachmentPolicyProvider.getElementPolicy:198] Failed to build
the policy 'WS2007FederationHttpBinding_IStoreService_policy':sp:HttpsToken
must have an inner wsp:Policy element
Exception in thread "main" java.lang.IllegalArgumentException:
sp:HttpsToken must have an inner wsp:Policy element
at
org.apache.wss4j.policy.builders.HttpsTokenBuilder.build(HttpsTokenBuilder.java:55)
at
org.apache.wss4j.policy.builders.HttpsTokenBuilder.build(HttpsTokenBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:108)
at
org.apache.wss4j.policy.builders.TransportTokenBuilder.build(TransportTokenBuilder.java:41)
at
org.apache.wss4j.policy.builders.TransportTokenBuilder.build(TransportTokenBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:108)
at
org.apache.wss4j.policy.builders.TransportBindingBuilder.build(TransportBindingBuilder.java:44)
at
org.apache.wss4j.policy.builders.TransportBindingBuilder.build(TransportBindingBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getAllOperator(PolicyBuilder.java:184)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:217)
at
org.apache.neethi.PolicyBuilder.getExactlyOneOperator(PolicyBuilder.java:180)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:215)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:124)
at
org.apache.cxf.ws.policy.attachment.reference.LocalServiceModelReferenceResolver.resolveReference(LocalServiceModelReferenceResolver.java:53)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.resolveLocal(Wsdl11AttachmentPolicyProvider.java:292)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.resolveReference(Wsdl11AttachmentPolicyProvider.java:272)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:220)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:168)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:161)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getEffectivePolicy(Wsdl11AttachmentPolicyProvider.java:98)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getAggregatedEndpointPolicy(PolicyEngineImpl.java:464)
at
org.apache.cxf.ws.policy.EndpointPolicyImpl.initializePolicy(EndpointPolicyImpl.java:152)
at
org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:140)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:604)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:316)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:303)
at
org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61)
at
org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318)
at
org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:338)
at
org.apache.cxf.transport.http.HTTPConduit.getClient(HTTPConduit.java:873)
at
org.apache.cxf.transport.http.HTTPConduit.configureConduitFromEndpointInfo(HTTPConduit.java:360)
at
org.apache.cxf.transport.http.HTTPConduit.finalizeConfig(HTTPConduit.java:440)
at
org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:242)
at
org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:226)
at
org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:233)
at
org.apache.cxf.endpoint.AbstractConduitSelector.createConduit(AbstractConduitSelector.java:145)
at
org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:107)
at
org.apache.cxf.endpoint.UpfrontConduitSelector.selectConduit(UpfrontConduitSelector.java:77)
at
org.apache.cxf.endpoint.ClientImpl.getConduit(ClientImpl.java:845)
at
com.reputation.r4e.integrator.centershift.handler.CenterShiftServiceConfigurator.configure(CenterShiftServiceConfigurator.java:18)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.createTestOperationManagerInstance(CentershiftSws2Client.java:52)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.getService(CentershiftSws2Client.java:33)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.main(CentershiftSws2Client.java:86)
I am very new to the ws-* support features. One of my customer gave a WSDL
to access their data. They are using Microsoft Identity Server for
authentication. I am using APACHE CXF library to develop this feature. I
read some document related to ws federation in CXF but I wasn't understand
the whole concept. I am posting my WSDL and client code and the error I am
getting. Can any one help me on this.?
Here the ws policy content from my WSDL
<wsp:Policy wsu:Id="WS2007FederationHttpBinding_IStoreService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken />
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256 />
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp />
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:IssuedToken
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<Issuer
xmlns="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<Address
xmlns="http://www.w3.org/2005/08/addressing">
https://slc.centershift.com/STS/issue/wstrust/mixed/username
</Address>
<Metadata
xmlns="http://www.w3.org/2005/08/addressing">
<Metadata
xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wsx:MetadataSection xmlns="">
<wsx:MetadataReference>
<Address
xmlns="http://www.w3.org/2005/08/addressing">https://slc.centershift.com/STS/issue/mex</Address>
</wsx:MetadataReference>
</wsx:MetadataSection>
</Metadata>
</Metadata>
</Issuer>
<sp:RequestSecurityTokenTemplate>
<trust:KeyType
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
</trust:KeyType>
<trust:CanonicalizationAlgorithm
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
<trust:EncryptionAlgorithm
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
</sp:RequestSecurityTokenTemplate>
<wsp:Policy>
<sp:RequireInternalReference />
</wsp:Policy>
</sp:IssuedToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
<sp:Wss11
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy />
</sp:Wss11>
<sp:Trust13
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:MustSupportIssuedTokens />
<sp:RequireClientEntropy />
<sp:RequireServerEntropy />
</wsp:Policy>
</sp:Trust13>
<wsaw:UsingAddressing />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
Here is the service end-point:
<wsdl:service name="StoreService">
<wsdl:port name="WS2007FederationHttpBinding_IStoreService"
binding="tns:WS2007FederationHttpBinding_IStoreService">
<soap12:address
location="https://slc.centershift.com/Store40/StoreService.svc" />
<wsa10:EndpointReference>
<wsa10:Address>
https://slc.centershift.com/Store40/StoreService.svc
</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
Client Code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.Executors;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.AddressingFeature;
import
com.reputation.r4e.integrator.centershift.handler.CenterShiftServiceConfigurator;
import
com.reputation.r4e.integrator.centershift.sws2.ArrayOfParameterValues;
import
com.reputation.r4e.integrator.centershift.sws2.GetDataViewResponse.GetDataViewResult;
import com.reputation.r4e.integrator.centershift.sws2.GetDataView_Request;
import com.reputation.r4e.integrator.centershift.sws2.IStoreService;
import com.reputation.r4e.integrator.centershift.sws2.ParameterValues;
import com.reputation.r4e.integrator.centershift.sws2.StoreService;
public class CentershiftSws2Client {
CenterShiftServiceConfigurator serviceConfigurator;
public IStoreService service;
/**
* Get the Test service instance for use. If the instance does not
create
* yet, create it.
*
* @return The service instance
*/
public IStoreService getService() {
if (service == null) {
service = createTestOperationManagerInstance();
}
return service;
}
/**
* Creates and returns the instance of the {@link TestOperationManager}
*
* @return instance of the {@link TestOperationManager}
*/
public IStoreService createTestOperationManagerInstance() {
StoreService service = new
StoreService(getWsdlLocation(StoreService.WSDL_LOCATION));
service.setExecutor(Executors.newCachedThreadPool());
IStoreService testOperationManagerSoap = service
.getWS2007FederationHttpBindingIStoreService(new
AddressingFeature(true));
getServiceConfigurator().configure(testOperationManagerSoap);
return testOperationManagerSoap;
}
/**
* Used to get the environment-specific location of the wsdl. If there
is no
* concept of an environment-specific location of the wsdl, then just
return
* the input codedWSDL
*/
public URL getWsdlLocation(URL codedWSDL) {
URL wsdlLocation = null;
try {
wsdlLocation = new
URL("https://slc.centershift.com/Store40/StoreService.svc?wsdl");
} catch (MalformedURLException mue) {
wsdlLocation = codedWSDL;
}
return wsdlLocation;
}
public CenterShiftServiceConfigurator getServiceConfigurator() {
return serviceConfigurator;
}
public void setServiceConfigurator(CenterShiftServiceConfigurator
centershiftServiceConfigurator) {
this.serviceConfigurator = centershiftServiceConfigurator;
}
public static void main(String[] args) {
CentershiftSws2Client testService = new CentershiftSws2Client();
CenterShiftServiceConfigurator serviceConfigurator = new
CenterShiftServiceConfigurator();
testService.setServiceConfigurator(serviceConfigurator);
IStoreService storeService = testService.getService();
((BindingProvider)
storeService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://slc.centershift.com/Store40/StoreService.svc");
((BindingProvider)
storeService).getResponseContext().put("ws-security.username.sct",
"USER_NAME");
((BindingProvider)
storeService).getResponseContext().put("ws-security.password.sct",
"PASSWORD");
GetDataView_Request dataView_Request = new GetDataView_Request();
dataView_Request.setOrgID("ORG_ID");
dataView_Request.setSiteID("SITE_ID");
dataView_Request.setViewName("VIEW_NAME");
ArrayOfParameterValues parameterValues = new
ArrayOfParameterValues();
ParameterValues paramters = new ParameterValues();
paramters.setFilterType(0);
paramters.setParameterName("start_date");
paramters.setParameterValue("2016-10-01T00:00:00.000-06:00");
parameterValues.getParameterValues().add(paramters);
dataView_Request.setParameters(parameterValues);
GetDataViewResult dataViewResult =
storeService.getDataView(dataView_Request);
List list = dataViewResult.getAny();
System.out.println(list.size());
}
}
StoreService Class:
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.1.7
* 2016-10-06T21:02:01.741+05:30
* Generated source version: 3.1.7
*
*/
@WebServiceClient(name = "StoreService",
wsdlLocation =
"https://slc.centershift.com/Store40/StoreService.svc?wsdl",
targetNamespace = "http://tempuri.org/")
public class StoreService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://tempuri.org/",
"StoreService");
public final static QName WS2007FederationHttpBindingIStoreService = new
QName("http://tempuri.org/", "WS2007FederationHttpBinding_IStoreService");
static {
URL url = null;
try {
url = new
URL("https://slc.centershift.com/Store40/StoreService.svc?wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(StoreService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}",
"https://slc.centershift.com/Store40/StoreService.svc?wsdl");
}
WSDL_LOCATION = url;
}
public StoreService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public StoreService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public StoreService() {
super(WSDL_LOCATION, SERVICE);
}
public StoreService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public StoreService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public StoreService(URL wsdlLocation, QName serviceName,
WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns IStoreService
*/
@WebEndpoint(name = "WS2007FederationHttpBinding_IStoreService")
public IStoreService getWS2007FederationHttpBindingIStoreService() {
return super.getPort(WS2007FederationHttpBindingIStoreService,
IStoreService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on
the proxy. Supported features not in the <code>features</code> parameter
will have their default values.
* @return
* returns IStoreService
*/
@WebEndpoint(name = "WS2007FederationHttpBinding_IStoreService")
public IStoreService
getWS2007FederationHttpBindingIStoreService(WebServiceFeature... features) {
return super.getPort(WS2007FederationHttpBindingIStoreService,
IStoreService.class, features);
}
}
Exception:
[WARN ][Wsdl11AttachmentPolicyProvider.getElementPolicy:198] Failed to
build the policy
'WS2007FederationHttpBinding_IStoreService_policy':sp:HttpsToken must have
an inner wsp:Policy element
Exception in thread "main" java.lang.IllegalArgumentException:
sp:HttpsToken must have an inner wsp:Policy element
at
org.apache.wss4j.policy.builders.HttpsTokenBuilder.build(HttpsTokenBuilder.java:55)
at
org.apache.wss4j.policy.builders.HttpsTokenBuilder.build(HttpsTokenBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:108)
at
org.apache.wss4j.policy.builders.TransportTokenBuilder.build(TransportTokenBuilder.java:41)
at
org.apache.wss4j.policy.builders.TransportTokenBuilder.build(TransportTokenBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:108)
at
org.apache.wss4j.policy.builders.TransportBindingBuilder.build(TransportBindingBuilder.java:44)
at
org.apache.wss4j.policy.builders.TransportBindingBuilder.build(TransportBindingBuilder.java:34)
at
org.apache.neethi.AssertionBuilderFactoryImpl.invokeBuilder(AssertionBuilderFactoryImpl.java:138)
at
org.apache.neethi.AssertionBuilderFactoryImpl.build(AssertionBuilderFactoryImpl.java:117)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:224)
at
org.apache.neethi.PolicyBuilder.getAllOperator(PolicyBuilder.java:184)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:217)
at
org.apache.neethi.PolicyBuilder.getExactlyOneOperator(PolicyBuilder.java:180)
at
org.apache.neethi.PolicyBuilder.processOperationElement(PolicyBuilder.java:215)
at
org.apache.neethi.PolicyBuilder.getPolicyOperator(PolicyBuilder.java:174)
at org.apache.neethi.PolicyBuilder.getPolicy(PolicyBuilder.java:124)
at
org.apache.cxf.ws.policy.attachment.reference.LocalServiceModelReferenceResolver.resolveReference(LocalServiceModelReferenceResolver.java:53)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.resolveLocal(Wsdl11AttachmentPolicyProvider.java:292)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.resolveReference(Wsdl11AttachmentPolicyProvider.java:272)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:220)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:168)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getElementPolicy(Wsdl11AttachmentPolicyProvider.java:161)
at
org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider.getEffectivePolicy(Wsdl11AttachmentPolicyProvider.java:98)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getAggregatedEndpointPolicy(PolicyEngineImpl.java:464)
at
org.apache.cxf.ws.policy.EndpointPolicyImpl.initializePolicy(EndpointPolicyImpl.java:152)
at
org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:140)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:604)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:316)
at
org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:303)
at
org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61)
at
org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318)
at
org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:338)
at
org.apache.cxf.transport.http.HTTPConduit.getClient(HTTPConduit.java:873)
at
org.apache.cxf.transport.http.HTTPConduit.configureConduitFromEndpointInfo(HTTPConduit.java:360)
at
org.apache.cxf.transport.http.HTTPConduit.finalizeConfig(HTTPConduit.java:440)
at
org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:242)
at
org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:226)
at
org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:233)
at
org.apache.cxf.endpoint.AbstractConduitSelector.createConduit(AbstractConduitSelector.java:145)
at
org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:107)
at
org.apache.cxf.endpoint.UpfrontConduitSelector.selectConduit(UpfrontConduitSelector.java:77)
at
org.apache.cxf.endpoint.ClientImpl.getConduit(ClientImpl.java:845)
at
com.reputation.r4e.integrator.centershift.handler.CenterShiftServiceConfigurator.configure(CenterShiftServiceConfigurator.java:18)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.createTestOperationManagerInstance(CentershiftSws2Client.java:52)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.getService(CentershiftSws2Client.java:33)
at
com.reputation.r4e.integrator.centershift.CentershiftSws2Client.main(CentershiftSws2Client.java:86)
*Questions:*
1. Do we have any end-end document related to ws federation/ws*- security
other than APACHE CXF document.?
2. Is my approach is right.?
3. How we need to communicate Microsoft Identity Server with APACHE CXF.?
4. Can any one provide a sample code related to this.?
Can any one help me on this. I was stuck over here.
Thanks & Regards, Arthur
--
View this message in context:
http://cxf.547215.n5.nabble.com/WS-Federation-client-impl-with-CXF-tp5773261.html
Sent from the cxf-user mailing list archive at Nabble.com.