Retrieve DelegateGroups and accounts associated with those groups from Salesforce - java

I am trying to bring in a set of groups called: DelegateGroup - Salesforce defines it as follows: DelegatedGroups
The meta data supplied shows the following:
<xsd:complexType name="DelegateGroup">
<xsd:complexContent>
<xsd:extension base="tns:Metadata">
<xsd:sequence>
<xsd:element name="customObjects" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="groups" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="label" type="xsd:string"/>
<xsd:element name="loginAccess" type="xsd:boolean"/>
<xsd:element name="permissionSets" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="profiles" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="roles" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
However this wasn't introduced until v36 so I went in and upgraded the Soap stubs to v46 - I am able to pull data from Salesforce, but I haven't figured out how to retrieve the DelegateGroup or how the accounts are associated with the delegategroup.
Note: The reason for the java tag is because I am coding this in Java.

Delegated Administrators can't be retrieved/deployed via metadata api. I think at best you'll get group names/permissions but not who's actually assigned. We know DelegateGroup and DelegateGroupMember objects exist (you can find them in online lists of obscure Salesforce object id prefixes) but they aren't exposed via API. See also https://salesforce.stackexchange.com/questions/129/querying-delegated-administrators

Related

cvc-elt.1: Cannot find the declaration of element 'change-set'

I'm trying to use some open-source software for RFID services (GitHub: fosstrak capturing application) from a few years ago and there's this error that I can't fix.
(null: 3, 230): cvc-elt.1: Cannot find the declaration of element 'change-set'.
I'm using Docker to containerise the application running Tomcat7 with Java8.
The XML looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0/change-set.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">
<add>
<resource source="classpath:drools/SimpleEPCISDocument.drl" type="DRL" />
</add>
</change-set>
And the XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:change-set="http://drools.org/drools-5.0/change-set">
<xsd:import namespace="http://www.w3.org/2001/XMLSchema-instance"/>
<xsd:element name="change-set">
<xsd:complexType>
<xsd:choice>
<xsd:element ref="change-set:add"/>
<xsd:element ref="change-set:remove"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="add">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="change-set:resource"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="remove">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="change-set:resource"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="resource">
<xsd:complexType>
<xsd:sequence>
<xsd:any minOccurs="0"/>
<xsd:element minOccurs="0" ref="change-set:decisiontable-conf"/>
</xsd:sequence>
<!-- URL to the resource, can be file based -->
<xsd:attribute name="source" use="required" type="xsd:anyURI"/>
<!-- for example, DRL, or PKG -->
<xsd:attribute name="type" use="required" type="xsd:string"/>
<xsd:attribute name="basicAuthentication" type="xsd:string"/>
<xsd:attribute name="username" type="xsd:string"/>
<xsd:attribute name="password" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="decisiontable-conf">
<xsd:complexType>
<xsd:attribute name="input-type" use="required" type="xsd:NCName"/>
<xsd:attribute name="worksheet-name" use="required" type="xsd:NCName"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Change
xs:schemaLocation="http://drools.org/drools-5.0/change-set.xsd [...]
to
xs:schemaLocation="http://drools.org/drools-5.0/change-set [...]
because schemaLocation must be a series of pairs of namespace URIs and XSD locations. In this case, the namespace URI is http://drools.org/drools-5.0/change-set, which matches the namespace of the root element in your XML and the target namespace of your XSD.
See also
How to reference a local XML Schema file correctly?
You'll also have to deal with a subsequent Unique Particle Attribute issue, but that's a separate matter deserving its own question if you're unable to resolve. Start with XSD validation - ANY in SEQUENCE ("Unique Particle Attribution").

MULE ESB Simple SOAP service create mandatory fields

I want to expose a Simple SOAP web service in Mule 3.4 Community.
Some fields of the service need to be mandatory/required. How can that be done?
Here is the web service method:
public String methodname(String field1, String field2, String field3);
Here is the resulting wsdl:
<xsd:element minOccurs="0" name="field1" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="field2" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="field3" nillable="true" type="xsd:string"/>
How can I make these fields minOccurs="1" and nillable="false"
Please note #XmlElement(required=true) doesn't work with my Java version 1.6
minOccurs="1" makes the element mandatory and minOccurs="0" makes it optional
So make the following change to make it mandatory:-
<xsd:element minOccurs="1" name="field1" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="1" name="field2" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="1" name="field3" nillable="true" type="xsd:string"/>
For your reference :- https://social.msdn.microsoft.com/Forums/en-US/f59a3ee2-5997-4ee7-8c09-8d371c923267/creating-required-elements-in-xsd?forum=xmlandnetfx
and
How to tell if XML element is marked as required in the XSD file
and nillable is specifies whether an explicit null value can be assigned to the element
reference:-http://www.w3schools.com/schema/el_element.asp
So you need to make change in your WSDL so that the Java class generated from to implements those properties of attributes
I'm afraid you can't do this with a simple service (as it's simple by definition, it would probably work latter versions of java as you point).
You should switch to a fullfeatured jaxws service without autogenerated wdsl.

CXF: generated WSDL vs. original WSDL

I have a question regarding WSDLs generated from CXF. From what I understood is that the WSDL that’s published by CXF is generated from JAX-WS/JAXB.
I have a WSDL file with the following content:
...
<xsd:complexType name="Scenario" mixed="true">
<xsd:sequence>
<xsd:element name="Description" type="xsd:anyURI" minOccurs="0"/>
<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>
...
After I generated my classes and deployed the service I checked the interface in my browser (with ?wsdl). Much to my surprise it looked considerably different: a "choice" has been added, processContents is changed, etc.
...
<xsd:complexType mixed="true" name="Scenario">
<xsd:sequence>
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element name="Description" type="xsd:string"/>
<xsd:any namespace="##other" processContents="lax"/>
<xsd:choice>
</xsd:sequence>
<xsd:anyAttribute namespace="##other" processContents="skip"/>
</xsd:complexType>
...
I am especially interested in this additional choice that’s been added?
Is it maybe because of the "xsd:any"?

refactoring xsd elements with same elements?

I have below xsd elements.
<xsd:element name="requestOne" type="tns:RequestOne"/>
<xsd:complexType name="RequestOne">
<xsd:annotation>
<xsd:documentation>some comment</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="requestTwo" type="tns:RequestTwo"/>
<xsd:complexType name="RequestTwo">
<xsd:annotation>
<xsd:documentation>other comment</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
It has two complex elements but inside them there is duplicated code. How can i refactor above code?
Thanks!
Instead of creating a new element you can use ref to refer to an existing one, tns in the sample below refers to the name space defined by the schema
<xsd:element name="id" type="xsd:string"/>
...
<xsd:complexType name=RequestOne">
<xsd:sequence>
<xsd:element ref="tns:id" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
...
Though, this does not really reduces the number of characters to write, in that simple case. You might even have a look at how to define abstract types which, similar to object orientated languages, get inherited by children:
<xsd:complexType name="AbstractType" abstract="true">
<xsd:sequence>
<xsd:element name"BaseType">
<xs:complexType>
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1" >
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
the children now need to inherit from the abstract type in the following manner:
<xsd:complexType name="ChildOne">
<xsd:complexContent>
<xsd:extension base="tns:AbstractType">
<xsd:element name="newElement" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Where newElement is just a new element defined by the child.
Edit: to be more precise, the id element is not really inherited like in an object oriented language but you achieve the same effect. The difference is, that you have to add the base-type within the XML of the concrete realization.
<ChildOne>
<BaseType>
<id>someId</id>
</BaseType>
<!-- elements defined by child one goes here -->
<newElement>new Element</newElement>
</ChildOne>

Content type exception thrown for xsd validation in elements

I have an element A which can be of simple element as well as complex which gets created dynamically.
sample xml is here :
<A>john</A>
<A>
<B>kathy</B>
<C> bat </C>
</A>
my xsd is like this :
<xsd:element name="A">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:sequence>
<xsd:element name="B" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="C" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:choice>
</xsd:complexType>
</xsd:element>
But here i am facing an exception which says :
Element 'A' cannot have character [children], because the type's content type is element-only
You need to specify mixed content in your type:
<xsd:element name="A">
<xs:complexType mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:sequence>
<xsd:element name="B" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="C" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:choice>
</xsd:complexType>
Also it's a bit redundant having a sequence inside a choice. You either want a sequence or not.
Hope that helps.

Categories