6

I have a very simple apex class:

global class RetrieveOpportunity {
  webservice static Opportunity retrieveOpportunity(Id opportunityId) {
    return new Opportunity();
  }
}

I clicked the Generate WSDL button on this class, and was able to generate successfully, it created a 7,695 line xml file.

When importing this into SoapUI, I get the error:

Error: type 'address@http://soap.sforce.com/schemas/class/RetrieveOpportunity' not found.

What am I missing?

7

UPDATE: There is now a known issue for this that you can track "Generate WSDL" generates a WSDL that does not contain the definition of the compound types address and location if API version is 30.0 or above


I've seen this before , but can't find the previous occurrence at the moment in Issue with Adding reference Webservice WSDL to VS2010.

There is a problem with the generated WSDL. It has several elements defined like:

<xsd:element name="BillingAddress" minOccurs="0" type="tns:address" nillable="true"/>

Note the type="tns:address". This says there should be a complex type in the http://soap.sforce.com/schemas/class/DFB/RetrieveOpportunity namespace (which is what tns maps to).

However, there isn't an "address" complex type defined in the WSDLs schema.

One option would be to define the required complex type yourself.

Here is the required definition extracted from the Partner API WSDL (v31.0) that should be added to the xsd:schema where the targetNamespace is "http://soap.sforce.com/schemas/class/DFB/RetrieveOpportunity".

<!-- Compound datatype: Address -->
        <complexType name="address">
            <complexContent>
                <extension base="tns:location">
                    <sequence>
                        <element name="city" type="xsd:string"  nillable="true" />
                        <element name="country" type="xsd:string"  nillable="true" />
                        <element name="countryCode" type="xsd:string"  nillable="true" />
                        <element name="postalCode" type="xsd:string"  nillable="true" />
                        <element name="state" type="xsd:string"  nillable="true" />
                        <element name="stateCode" type="xsd:string"  nillable="true" />
                        <element name="street" type="xsd:string"  nillable="true" />
                    </sequence>
                </extension>
            </complexContent>
        </complexType>

<!-- Compound datatype: Location -->
        <complexType name="location">
            <sequence>
                <element name="latitude" type="xsd:double"  nillable="true" />
                <element name="longitude" type="xsd:double"  nillable="true" />
            </sequence>
        </complexType>

I've raised this on the developer forum to see if will get picked up as a bug. Salesforce generated WSDL for Apex webservice missing address complex type

  • 1
    That did it, thanks. I appended that directly inside xsd:schema in the generated xml. – Ray Dehler Nov 12 '14 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.