Set up a mock service to test against
Java version
2. https://tomcat.apache.org/download-80.cgi 32-bit/64-bit Windows Service Installer (pgp, sha512)
3. https://stackoverflow.com/questions/30094103/tomcat-configuration-in-eclipse
4. xsd - How to reference a local XML Schema file correctly? - Stack Overflow
5. https://stackoverflow.com/questions/43866503/how-to-generate-mock-web-service-using-wsdl-in-java
Setup SSL
https://tomcat.apache.org/tomcat-8.5-doc/ssl-howto.html
cd C:\Program Files\Java\jre1.8.0_251
keytool -genkey -alias tomcat -keyalg RSA -keystore C:\_src\MockServices\Servers\service.jks
Modify tomcat server.xml:<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="443"/>
<Connector port="443"
protocol="HTTP/1.1"
maxThreads="250" SSLEnabled="true" scheme="https"
secure="true"
keystoreFile="C:_src\MockServices\Servers\service.jks"
keystorePass="Password1"
clientAuth="false" sslProtocol="TLS"
sslEnabledProtocols="TLSv1.2"
URIEncoding="UTF-8"
/>
SOAP XML Integration
Method 1 - WSDL
Alter your WSDL so that it references the XSD in the same directory.
In VS, Tools, Command Line, Developer tools, enter this command
wsdl Service.wsdl Service.xsd /username: xxxxxxxx /password: xxxxxxxx
This will generate a service class.
Put the class in its own project, and add a reference to Microsoft.Web.Services2 using nuget.
Add a reference to system.web.services using Assemblies:
Modify the generated class:
· Change name of class suffix from ServiceService to ServiceClient (pure aesthetics).
· Change parent class to Microsoft.Web.Services2.WebServicesClientProtocol
· Change default URL to a useful value.
· Add a constructor that accepts the service point URL.
Write a client class that calls the generated code. e.g.
Security references
The point of using wsdl.exe rather than WCF is so that we can manipulate the SOAP security settings.
These resources were used when looking at security:
https://stackoverflow.com/questions/14869602/add-wsse-soap-header-to-web-reference/67310603#67310603
https://stackoverflow.com/questions/5833539/how-to-add-security-header-to-a-soap-message
Method 2 - WCF
Do not use this method if you need to adjust the security configuration.
https://medium.com/grensesnittet/integrating-with-soap-web-services-in-net-core-adebfad173fb
The c# project needs to be a Class Library (.NET standard)
right click on the project after it is created and then add a connected service. Enter the wsdl location and the code will then be generated.
No comments:
Post a Comment