function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VZVZ 

Element or attribute do not match QName production: QName::=(NCName':')?NCName.

Hi,

I am using the partner wsdl for the purpose of integration. I got the complete functionality working with the enterprise wdl. I changed the code to make it work with partner wsdl but I am getting an exception at the time of "create" call. The exception goes like this....

AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':&apos?NCName.

faultActor:

faultNode:

faultDetail:

{http://xml.apache.org/axis/}stackTrace: AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':&apos?NCName.

faultActor:

faultNode:

faultDetail:

There is some problem with the Namespace but I have no clue. Can anyone please help me with this?

 

Thanks in advance,

VZ

DevAngelDevAngel

Hey VZ,

Can you attach or post the actual soap message for the create call?

 

Thanks

VZVZ

Hi,

Thanks for the assistance but I could not get the actual SOAP message, am attaching here the code that I have written for CREATE and also the code in the SoapBindingStub.java

My Code:

SObject[] opLineItem = new SObject[1];

MessageElement[] createOpLineItem = new MessageElement[7];

createOpLineItem[0] = new MessageElement("TotalPrice",TotalPrice);

createOpLineItem[1] = new MessageElement("Quantity",Quantity);

createOpLineItem[2] = new MessageElement("OpportunityId",OpId);

createOpLineItem[3] = new MessageElement("Description",Desc);

createOpLineItem[4] = new MessageElement("QuoteID__c",QuoteId);

createOpLineItem[5] = new MessageElement("CartID__c",CartId);

createOpLineItem[6] = new MessageElement("ProductId",this.getProductId(ProdName,PriceBook));

opLineItem[0] = new SObject();

opLineItem[0].setType("OpportunityLineItem");

opLineItem[0].set_any(createOpLineItem);

SaveResult[] saveResults = null;

try {

saveResults = binding.create(opLineItem);

} catch (Exception e) {

System.out.println(e.getMessage());

e.printStackTrace();

return;

}

SoapBindingStub.java

org.apache.axis.client.Call _call = createCall();

_call.setOperation(_operations[3]);

_call.setUseSOAPAction(true);

_call.setSOAPActionURI("");

_call.setEncodingStyle(null);

_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);

_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);

_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);

_call.setOperationName(new javax.xml.namespace.QName("urn:partner.soap.sforce.com", "create"));

setRequestHeaders(_call);

setAttachments(_call);

java.lang.Object _resp = _call.invoke(new java.lang.Object[] {sObjects});

 

I think that I am not setting the namespace or something because of which it is not working. The exact error is as following:

AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':&apos?NCName.

faultActor:

faultNode:

faultDetail:

{http://xml.apache.org/axis/}stackTrace: AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':&apos?NCName.

faultActor:

faultNode:

faultDetail:

org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)

at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)

at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)

at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)

at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)

at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1204)

at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)

at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:393)

at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)

at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)

at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)

at org.apache.axis.client.Call.invokeEngine(Call.java:2583)

at org.apache.axis.client.Call.invoke(Call.java:2553)

at org.apache.axis.client.Call.invoke(Call.java:2248)

at org.apache.axis.client.Call.invoke(Call.java:2171)

at org.apache.axis.client.Call.invoke(Call.java:1691)

at com.sforce.soap.partner.SoapBindingStub.create(SoapBindingStub.java:1025)

at com.sforce.SFDCMethods.createOpportunityLineItem(SFDCMethods.java:689)

at com.sfdc.plugins.ConnectSForce.createLineItem(ConnectSForce.java:63)

at com.sfdc.plugins.MainClass.main(MainClass.java:37)

Please help,

VZ

 

DevAngelDevAngel

Hi VZ,

Not sure where the problem lies.  TCPMON is great for getting the actual soap messages.

In the mean time, this wrapper for the new MessageElement strips alot of the automatically generated attributes, one of which might be causing the problem.  Call this function instead of the inline new MessageElement() and see if it helps.

private MessageElement newMessageElement(String name, Object value) throws Exception

{

MessageElement me = new MessageElement("", name); //, value);

me.setObjectValue(value);

Element e = me.getAsDOM();

e.removeAttribute("xsi:type");

e.removeAttribute("xmlns:ns1");

e.removeAttribute("xmlns:xsd");

e.removeAttribute("xmlns:xsi");

me = new MessageElement(e);

return me;

}

Cheers

treemarktreemark

I'm having the same issue. I'm working on getting TCPMon installed to capture the soap messages. In the mean time, is there any new information on this problem? It's probebly worth noting that I have both partner and enterprise APIs compiled and running on this server. (Tring to migrate away from the enterprise API)

Mark Orr

SuperfellSuperfell
check exactly which constructor is getting used for the MessageElements, i think you'll find its not using the constructor you'd expect and its using the value for the namespace
treemarktreemark

Firstly, I am doing this in javascript so pardon the odd syntax. The code I'm writing is supposed to select all the contacts and leads associated with a campaign, export them to excel while populating a custom field if it is found to be null. Here is the code snippet that is failing...

var fuid = "xxxxx"; // fuid stands for 'friendly user ID"
var fuid = new java.lang.String(fuid); // make sure it's a java.lang.string
var FUID = new java.lang.String("FUID__c");  // The name of the custom column I'm updating
var fuidME= new Packages.org.apache.axis.message.MessageElement["(java.lang.String,java.lang.String)"](FUID,fuid); // long ugly syntax for calling an overloaded java method. note I am fully specifying the package for MessageElement. translated to Java it would look like this:
//MessageElement fuidME = new org.apache.axis.message.MessageElement(FUID,fuid);
var el = fuidME.getAsDOM(); <-- throws error.


I'm running both the partner and enterprise apis at the same time, by generating both sets of java files with the wsdl2java utility and compiling the result, using SalesForce.com.QuickStart3.0.jar in my classpath for the axis dependancies. From what your saying, it sounds likely that I bungled it up there. Can you outline the steps I should take to compile and run both APIs?

SuperfellSuperfell
The MessageElement(String, String) constructor for MessageElement is
public MessageElement(String namespace, String localPart)

As you're trying to specify a name and value, you should probably be using
public MessageElement(String namespace, String localPart, Object value)
(but don't get it confused with public MessageElement(String localPart, String prefix, String namespace), which is different and something of a bungle by the axis folks)

or use the cleaner
public MessageElement(QName name, Object value)
treemarktreemark

Thank you, switching to the (QName, Object) signature fixed the problem. However, your example code in the partner API section clearly shows the (String, String) signature being used. Maybe that documenation could use an update.

Thanks again for the speedy replies.

Mark Orr
Chief Architect
enContext Solutions Inc