Home > soap api > ref an Element in another Namespace using WSDL2Apex and SOAP API webservice call

ref an Element in another Namespace using WSDL2Apex and SOAP API webservice call

December 18Hits:2

I am trying to integrate with a web service which utilises two namespaces, and has elements which need to reference the other namespace. For example:

<xsd:schema targetNamespace="http://namespace1.com" elementFormDefault="qualified" attributeFormDefault="unqualified">     <xsd:complexType name="GetLocationLocationType">         <xsd:sequence>             <xsd:element ref="oa:Address"/>         </xsd:sequence>     </xsd:complexType> <xsd:/schema>  <xsd:schema targetNamespace="http://namespace2.com" elementFormDefault="qualified" attributeFormDefault="unqualified">     <xsd:element name="Address" type="oa:LocationAddressLineType"/> <xsd:/schema> 

This compiles correctly into Apex code as below:

public class GetLocationLocationType  {     public bg_WSAddressOpenAppResources.LocationAddressLineType Address;     private String[] Address_type_info = new String[]{'Address','http://www.namespace2.com',null,'1','1','false'};     private String[] apex_schema_type_info = new String[]{'http://www.namespace1.com','true','false'};     private String[] field_order_type_info = new String[]{'Address'}; }   public class LocationAddressLineType  {     public String AddressLine;     public String CountryCode;     public String PostalCode;     public bg_WSAddressOpenAppResources.StatusType Status;     private String[] AddressLine_type_info = new String[]{'AddressLine','http://www.namespace2.com',null,'0','1','false'};     private String[] CountryCode_type_info = new String[]{'CountryCode','http://www.namespace2.com',null,'0','1','false'};     private String[] PostalCode_type_info = new String[]{'PostalCode','http://www.namespace2.com',null,'0','1','false'};     private String[] Status_type_info = new String[]{'Status','http://www.namespace2.com',null,'0','1','false'};     private String[] apex_schema_type_info = new String[]{'http://www.namespace2.com','true','false'};     private String[] field_order_type_info = new String[]{'AddressLine', 'CountryCode','PostalCode','Status'}; } 

The issue I'm having is that when the SOAP message is received by the web service, any elements which were used in namespace1 but stored in namespace2 (such as the GetLocationLocationType -> LocationAddressLineType relationship) were incorrectly sent as a namespace1 element (and thus treated as null by the web service).

Therefore my question (eventually!) is whether there is a way to get around the restriction for using 'ref' tags in a WSDL which reference a different namespace? The documentation relating to this restriction can be found here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm

xsd:element. In Apex code saved using API version 15.0 and later, the ref attribute is also supported with the following restrictions:

You cannot call a ref in a different namespace.

Hopefully I've provided enough information, if anything else is needed please let me know. Any advice would be appreciated.


I've studied the output code from the WSDL2Apex tool quite a lot for various reasons like this, for example it ignoring xsd:extension. Some can be worked around by modifying the generated code, thus its really a restriction in code generator and not the XML binding annotation you've shown in your question. In this case however, i see that it did correctly generate the annotation with the correct namespace, so in this case there is no such option to modify the code.

I'm sorry but this looks like a real restriction.

Related Articles

  • ref an Element in another Namespace using WSDL2Apex and SOAP API webservice callDecember 18

    I am trying to integrate with a web service which utilises two namespaces, and has elements which need to reference the other namespace. For example: <xsd:schema targetNamespace="http://namespace1.com" elementFormDefault="qualified"

  • Set XML element to no namespace in XSD?January 27

    I'm trying to validate XML according to an XSD. In this XML there are tags with namespaces and without. <my:person xmlns:my="http://my.namespace.com"> <my:name>John Doe</my:name> <my:year>1988</my:year> <namespac

  • How to refer to element using jQueryFebruary 2

    I am trying to get the value that is already existing in HTML element and pass it to another using jQuery. I ma not sure if I am referring to the element incorrectly as it returns Not a number value. Can you please look at my code and help: var oldPr

  • Is POST for an element generally not exposed or invalid in REST APIs?October 1

    I was browsing around wikipedia on REST, reading specifically the section on REST APIs Reading the different ways to treat elements from collections I read that POST is not generally used. How does that work in practice? When successful REST APIs are

  • Metadata SOAP API can't parse response, Apex type not found for elementMay 7

    I've generated an Apex class based on the Metadata WSDL file I got from my org. I call the readMetadata function and while the response received contains all the data I want, the callout fails because of 'Apex type not found for element language'. Wh

  • How do I register components in nested namespaces using Castle's Fluent API?January 19

    I have classes in my project that reside in sub-namespaces of some generic namespace. For instance: ClassFoo, ClassFoo1, ClassFoo2 in namespace MyProject.GeneralNamespace.NamespaceA ClassBar, ClassBar1, ClassBar2 in namespace MyProject.GeneralNamespa

  • Savon request with elements that don't belong to a namespaceFebruary 1

    I am using Savon 2.11.1 as a Ruby SOAP client. I create client with the following code: client = Savon.client( :wsdl => "#{wsdl_file}", env_namespace: :soapenv, # changes env namespace to soapenv namespace in requests :logger => Rails.logg

  • ColdFusion XmlSearch(): XPath with namespacesJanuary 25

    <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><env:Header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="htt

  • OleDbConnection not found while using System.data namespace in codeFebruary 16

    In my code, I am using OleDbConnection, While I refer to System.Data, it gives me the error that OleDbConnection not found, But when I refer to System.Data.OleDb; namespace then it runs fine, Why is this error occurring..? I checked for the reference

  • SimpleXML and namespacesOctober 20

    There's a lot about SimpleXML, PHP5's new API for accessing the contents of XML documents, in SitePoint's recently-published book No Nonsense XML Web Development With PHP, but one thing it doesn't cover is how to use SimpleXML with a document that ma

  • How do I turn the Chrome Developer Tools element highlighting back on?April 7

    Somehow I turned off the highlighting in Chrome Developer Tools, so now when I select an element in the Elements panel, I don't see the element highlighted on the page. There must be a keyboard shortcut I pressed accidentally that toggles this. Does

  • Read a namespaced attribute from a SimpleXmlElement (imported from XMLReader)May 14

    I'm trying to read a large xml file (about 40 MB), and use this data for update the db of my application. It seems i've found a good compromise in terms of elapsed time/memory using XMLReader and simplexml_import_dom() but i can't get the value of at

  • Element {} item is invalid Can anyone explain this error?February 13

    When we are connecting to sfdc from php using the SOAP API we are receiving an error message: Element {} item is invalid How can i resolve my issuse ini_set("soap.wsdl_cache_enabled", "0"); ini_set(E_ALL,1); ini_set('display_errors',1)

  • What wattage heating element required for 500 degree Celsius oven temperature

    What wattage heating element required for 500 degree Celsius oven temperatureDecember 7

    i have 32 litres OTG oven which is of 2000 watts and can generate Max. 250 degree Celsius . 40 Litre capacity 2000 watts OTG has 2 heating elements, one at top and one at bottom. so each heating element is of 1000 watts, when i am on broil mode only

  • Namespace set as Used because of One Type Inside being Used?January 14

    I just noticed this. I don't know why this is the case, if i use one element from a namespace i don't want anything else to be accessible without having to use the namespace. For example here, this code is valid: namespace Test { struct Magic { int p

  • Dynamic output namespace for imported templatesJanuary 18

    I have a simple XSL that uses an import: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://ex1"> <xsl:import href="import.xsl" /> <xsl:template match="/

  • Element 'content' is already used with @org.simpleframework.xml.ElementJanuary 18

    I took an example of the web (http://www.hermosaprogramacion.com/2015/05/tutorial-para-crear-un-lector-rss-en-android/) of a RSS Reader. Uses the RSS structure from forbes: <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://p

  • Pass this.refs as property in jsx in React.jsJanuary 19

    I'm trying to pass 1 node as a property of another React component like this: render: function() { return ( <div> <div ref='statusCircle'></div> <Popover trigger={ this.refs.statusCircle }></Popover> </div>); ); } But i

  • XSLT to handle namespace prefixes with different URLsJanuary 21

    I have incoming XML files from different systems with namespaces declared for the current version of the message. Example: xmlns:abc="MatchingVersion_6-0" I parse this without issue using a small XSLT sheet. One of the feeding systems has now up

  • adding namespaces to XML with boostJanuary 28

    I'm trying to generate an xml using boost. Going fine so far, but the xml that gets generated needs to have a namespace. so instead of <name>"Harry"</name> it would say <ns1:name>"Harry"</ns1:name> Is there any

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.540 s.