Giter VIP home page Giter VIP logo

wsdl2apex's Introduction

WSDL2Apex

WSDL2Apex takes a WSDL file and generates the Apex stubs for it. This is used in, and is part of the Force.com IDE plug-in. However, since it can be used a standalone tool, we have factored it out into its own project.

How to Use

  1. Clone this repository.
  2. In the directory, use the command mvn install package.
  3. After it has finished, use the command cd target to switch to the right directory
  4. Execute the jar: java -jar WSDL2Apex-1.0.jar [path-to-wsdl] [path-to-new-file] [want asynchronous class? (yes|no)]
  5. To clean, run mvn clean

To run the test, use the command mvn test in the base directory

Note

WSDL2Apex code is now separated into the parsing part and the generated part. If you are using the parsing and generating functions in the main class, be sure to use the parse method first and then the generate method.

Parse method takes [path-to-wsdl]

Generate method takes in [names-of-generated-classes] [want asynchronous class? (yes|no) ] [(optional) path-to-new-file]

License

Eclipse Public License (EPL) v1.0

WSDL2Apex also uses the following libraries/frameworks in their binary form, which have their own respective licenses:

wsdl2apex's People

Contributors

fishofprey avatar svc-scm avatar vazexqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsdl2apex's Issues

Suggestion - generate unit-test classes for generated Soap classes

generated Soap classes can be quite big, and that adds a lot of lines to be covered by unit-tests (as Salesforce demands 70% coverage of apex code, if I remember correctly).

There is a systematic way of generating "dumb" unit-tests for these classes, and I think it can be generated by this tool as well.

Apex class names ending with 'Exception'

Classes coming from Complex Types that end in 'Exception' need a suffix so that Apex doesn't require them to extend the inbuilt Exception class.

E.g. If the WSDL contains the following complexType the resulting Apex class can't be deployed.

<xs:complexType name="CloudAPIException">
    <xs:sequence>
        <xs:element name="message" type="xs:string" minOccurs="0"></xs:element>
    </xs:sequence>
</xs:complexType>

Maven run of the test cases produces 15 failures in Windows.

Calls to FileString.getStringFromFile(String Path) are returning strings that have both LF and CRLF as the delimiter in a Windows environment.

This results in 15 test failures when comparing the WSDL2Apex output with the expected output files.


Test set: com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest

Tests run: 47, Failures: 15, Errors: 0, Skipped: 0, Time elapsed: 0.686 sec <<< FAILURE!
testAsyncFalse(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest) Time elapsed: 0.032 sec <<< FAILURE!
org.junit.ComparisonFailure: Test 8 doesn't match expected:<> but was:<...nerated by wsdl2apex[

]
}> but was:<...nerated by wsdl2apex[
}]
}>
at org.junit.Assert.assertEquals(Assert.java:115)

testNewClassNames(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest) Time elapsed: 0.038 sec <<< FAILURE!

The result1 output of parseAndGenerate(args) has the extra CR.

My quick hack solution is to modify the return statement of FileString.getStringFromFile() by appending .replaceAll("\r\n", "\n").

Also, are the last two arguments to assertEquals around the correct way? Should the expected value go first and then the actual value?

I might be off the mark of both these points as I don't usually work with Java.

Errors while compiling using 'mvn install package'

When I run mvn install package I get the error.log below.

What can I do to fix it?

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: simpleType->element Name can not be null. 2640:41

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: Unable to find schema type for element ElementWithNoSchemaType
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Failed to parse WSDL: Unable to find binding {urn:dotnet.callouttest.soap.sforce.com}IDontExist. Found DotNetInteropTestServiceSoap instead.

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to get type for operation '{http://doc.sample.com/docSample}EchoString' due to Unsupported WSDL. Found more than one part for message EchoStringSoapIn
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unable to find wsdl:service in the specified wsdl

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unsupported WSDL style 'rpc'. Only supports Dcoument/literal/wrapped services. 24:57

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Unsupported schema type: {http://www.w3.org/2001/XMLSchema}gDay
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unable to find binding in port DotNetInteropTestServiceSoap

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: Unable to find element for {urn:dotnet.callouttest.soap.sforce.com}EchoStringResponse
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: Unable to find Schema type for TestHeader
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Parse error: Found invalid XML. only whitespace content allowed before start tag and not t (position: START_DOCUMENT seen t... @1:1)

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to get type for operation '{http://doc.sample.com/docSample}EchoString' due to Unsupported WSDL. No part found for message: EchoStringSoapIn
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Class name 'Metadata' already in use. Please edit WSDL to remove repeated names
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Unable to find type definition for schema type: {http://tempuri.org/}DNSInfo-xxx Due to: Unable to find complexType for {http://tempuri.org/}DNSInfo-xxx
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: Unsupported WSDL. No part found for message: EchoStringSoapOut
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unable to find wsdl:binding in the specified wsdl

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Unsupported schema type: {http://www.w3.org/2001/XMLSchema}IDontExist
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unable to find port in wsdl:service

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unsupported Schema element found http://www.w3.org/2001/XMLSchema:include. At: 13:51

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unsupported WSDL style 'rpc'. Only supports Dcoument/literal/wrapped services. 25:60

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Found more than one wsdl:portType. WSDL with multiple portType not supported

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: Unsupported WSDL. Found more than one part for message EchoStringSoapOut
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Found schema import from location AlexaWebSearch.xsd. External schema import not supported

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unable to find wsdl:portType in the specified wsdl

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Unable to find soap 1.1 address
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to get type for operation '{urn:dotnet.callouttest.soap.sforce.com}EchoBoolean' due to Element not defined for part 'parameters'
Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Parse error: Found invalid XML. processing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \r\n<?xml ... @2:7)

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Unexpected element 'complexType' at: 19:37

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: targetNamespace not specified in wsdl:definitions

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doParse
SEVERE: Failed to parse wsdl: Found a fault without name

Jan 08, 2019 12:17:37 PM com.salesforce.ide.wsdl2apex.core.WSDL2Apex doGenerate
SEVERE: Failed to parse wsdl: com.sforce.ws.ConnectionException: No message found for:{urn:dotnet.callouttest.soap.sforce.com}MeNeither

Build fails with test failures

Building on Mac OS X 10.10.5 (Yosemite), fresh install of Maven via brew install maven, java:

> $ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

Running mvn install produces the following:

Results :

Failed tests:   testAsyncFalse(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test 8 doesn't match expected:<...rmationByAirportCode[Response_element {(..)
  testNewClassNames(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): testNewClassNames doesn't match expected:<... }(..)
  testNoOperation(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test noOperation failed expected:<...   public class Echo[Date_element {(..)
  testExchange(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test testExchange failed expected:<...{(..)
  testAmazonGood(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test testAmazonGood failed expected:<... {(..)
  testBigFile(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test testBigFile failed expected:<... {(..)
  testNamespaceDependencies(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test testNamespaceDependencies failed expected:<... {(..)
  testTwoNamespaces(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): testTwoNamespaces a doesn't match, Async class expected:<...mple.com/stockquote.[wsdl', 'exampleComStockquoteWsdl', 'http://example.com/stockquote.xsd', 'exampleComStockquoteXsd]'};(..)
  testSqlMutations(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test sqlMutations failed expected:<...lic class getMutants[CompressedResponse_element {(..)
  testMultipleNamespace(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): Test testMultipleNamespace failed expected:<...   public class Echo[Date_element {(..)
  testLargeFile(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): testLargeFile a doesn't match expected:<...m/spectrum/services/[EOLS_PSAPLookupUS', 'wwwPbComSpectrumServicesEolsPsaplo', 'http://spectrum.pb.com/', 'spectrumPbCom', 'http://www.mapinfo.com/midev/service/geometries/v1', 'wwwMapinfoComMidevServiceGeometries', 'http://www.mapinfo.com/midev/service/units/v1', 'wwwMapinfoComMidevServiceUnitsV1', 'http://www.pb.com/spectrum/services/', 'wwwPbComSpectrumServic]es'};(..)
  testSimple(com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest): testSimple doesn't match expected:<...rmationByAirportCode[Response_element {(..)

Tests run: 47, Failures: 12, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.674 s
[INFO] Finished at: 2016-04-15T08:46:37-04:00
[INFO] Final Memory: 18M/260M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project WSDL2Apex: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/jclark/ext/WSDL2Apex/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Test results files attached; xml file extension changed to support uploading to github.

com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest.txt

TEST-com.salesforce.ide.wsdl2apex.core.WSDL2ApexTest.xml.txt

Integer and Boolean should be reserved keywords

The reserved keywords in ApexTypeMapper are missing "integer" and "boolean". These are required so that they pickup the "_x" suffix when used as a member name.

I'll create a pull request to add these.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.