[SalesForce] WSDL generated from apex can’t import to SoapUI

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?

Best Answer

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