Questions:I am not sure if I need a custombinding or wshttpsbinding.
This is my web.config
<bindings>
<!--<wsHttpBinding>
<binding name="EBinding">
<security mode="Transport" authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
<message clientCredentialType="IssuedToken"/>
--><!--Specifies the character encoding and message versioning used for text-based XML messages.--><!--
<textMessageEncoding messageVersion="Soap11"/>
<httpTransport/>
</security>
</binding>
</wsHttpBinding>-->
<customBinding>
<binding name="MHService_MHSPort">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'http://org/emedny/mhs/': -->
<!-- <wsdl:binding name='MHS'> -->
<!-- <dpe:summary xmlns:dpe="http://www.datapower.com/extensions">..</dpe:summary> -->
<!-- <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">..</sp:SupportingTokens> -->
<security mode="Transport" authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
<message clientCredentialType="IssuedToken"/>
<!--Specifies the character encoding and message versioning used for text-based XML messages.-->
<textMessageEncoding messageVersion="Soap11"/>
</security>
<!--Specifies the character encoding and message versioning used for text-based XML messages.-->
<textMessageEncoding messageVersion="Soap11"/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://12.23.28.113:9047/MHService"
binding="MHService_MHSPort" bindingConfiguration="MHService_MHSPort" contract="ProxyGeneration.MHS" name="MHSPort" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehaviorConfiguration">
<clientCredentials>
<clientCertificate findValue="LMWARD" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My"/>
<serviceCertificate>
<authentication revocationMode="NoCheck" certificateValidationMode="None"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
This is my wsdl
<wsdl:definitions xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://org/emedny/mhs/" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://org/emedny/mhs/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsp:Policy wsu:Id="policy0" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<sp:AsymmetricBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:InitiatorToken>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:X509Token>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssX509V3Token11 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:X509Token>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssX509V3Token11 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:RecipientToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:TripleDesRsa15 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:AlgorithmSuite>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:AsymmetricBinding>
<sp:SignedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<sp:Body />
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<sp:Body />
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="policy1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<dpe:summary xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:dpe="http://www.datapower.com/extensions">
<dppolicy:domain xmlns:dppolicy="http://www.datapower.com/policy">
http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702
</dppolicy:domain>
<description>
Implements WS Security Policy 1.2 - UsernameToken 1.0 support
</description>
</dpe:summary>
<sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssUsernameToken10 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:UsernameToken>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema>
<xsd:import schemaLocation="MHService.xsd1.xsd" namespace="http://org/emedny/mhs/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="getCCDResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getCCDResponse" />
</wsdl:message>
<wsdl:message name="getEligibilityRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getEligibility" />
</wsdl:message>
<wsdl:message name="getEligibilityResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getEligibilityResponse" />
</wsdl:message>
<wsdl:message name="getNCPDPHistoryRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getNCPDPHistory" />
</wsdl:message>
<wsdl:message name="getNCPDPHistoryResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getNCPDPHistoryResponse" />
</wsdl:message>
<wsdl:message name="getPDQRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getPDQRequest" />
</wsdl:message>
<wsdl:message name="MHSFault">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:Fault" />
</wsdl:message>
<wsdl:portType name="MHS">
<wsdl:operation name="getCCD">
<wsdl:input name="getPDQRequest" message="ns0:getPDQRequest" />
<wsdl:output name="getCCDResponse" message="ns0:getCCDResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
<wsdl:operation name="getEligibility">
<wsdl:input name="getEligibilityRequest" message="ns0:getEligibilityRequest" />
<wsdl:output name="getEligibilityResponse" message="ns0:getEligibilityResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
<wsdl:operation name="getNCPDPHistory">
<wsdl:input name="getNCPDPHistoryRequest" message="ns0:getNCPDPHistoryRequest" />
<wsdl:output name="getNCPDPHistoryResponse" message="ns0:getNCPDPHistoryResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MHS" type="ns0:MHS">
<soap11:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getCCD">
<soap11:operation soapAction="" style="document" />
<wsdl:input name="getPDQRequest">
<soap11:body use="literal" />
</wsdl:input>
<wsdl:output name="getCCDResponse">
<soap11:body use="literal" />
</wsdl:output>
<wsdl:fault name="MHSFault">
<soap11:fault use="literal" name="MHSFault" namespace="" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getEligibility">
<soap11:operation soapAction="" style="document" />
I dont have any kind of SOAp headers to use in my proxyclass. I am missing security headers for ws-security for web.config.
This is how the sample soap request header looks like
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mhs="http://org/emedny/mhs/" xmlns:urn="urn:hl7-org:v3">
<soapenv:Header>
<wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-e00c8062-83d2-4f04-88fc-996218e7bb3d">MIICeDCC....(eMedNY signed user MLS cert).......</wsse:BinarySecurityToken>
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-c0cc2cd4-cb77-4fa5-abfa-bd485afd1685">MIIDFj.....( eMedNY MLS web-service end-point public cert)........</wsse:BinarySecurityToken>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-970e9a80-00cc-4c86-8ec4-3ba16e029a5b">
<wsse:Username>....your_username.....</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">.....your_plaintext_password....</wsse:Password>
<wsse:Nonce>KNyu6MsXCkTg4DDyvwvEiw==</wsse:Nonce>
<wsu:Created>2010-09-15T18:00:30Z</wsu:Created>
</wsse:UsernameToken>
<xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference>
<wsse:Reference URI="#SecurityToken-c0cc2cd4-cb77-4fa5-abfa-bd485afd1685" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>gpBAWt91pdwhKva............</xenc:CipherValue>
</xenc:CipherData>
<xenc:ReferenceList>
<xenc:DataReference URI="#Enc-0641b860-b16d-4941-91c0-d60bece67794"/>
</xenc:ReferenceList>
</xenc:EncryptedKey>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
I am using wcf to do this.How do I actually generate the soap xml. I don't want to be hard coding all this.. Although I started to do this.
` soapXML = "http://schemas.xmlsoap.org/soap/envelope/\" xmlns:mhs=\"http://org/emedny/mhs/\" xmlns:urn=\"urn:hl7-org:v3\" >";
soapXML += "\n";
// Add security block for X.509 certificate
soapXML = "<wsse:Security soap:mustUnderstand=\"1\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">";
soapXML += "<wsse:BinarySecurityToken ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
soapXML += "EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
`
Even if I do how would I generate these security and binary tokens. This request uses ws-security..I am doing my research and reading about it to the best of my understanding.
Thank you
user
Related
I have a perl program that is accessing a soap server. when testing the soap server via SoapUI it works, but when using my perl program I get
Can't use an undefined value as an ARRAY reference at /Library/Perl/5.18/SOAP/WSDL.pm line 222.
Here is my perl script.
use SOAP::WSDL;
my $data = 'some data here';
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $client = SOAP::WSDL->new( 'wsdl' => "link_to_wsdl" );
my $result = $client->call('MyMethod', $data);
use Data::Dumper;
print Dumper($result);
Here is the WSDL
<?xml version="1.0"?>
<wsdl:definitions
name="Test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:APISoapServer"
targetNamespace="urn:APISoapServer"
>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:APISoapServer">
<xsd:element name="MyMethod">
<xsd:complexType>
<xsd:complexContent mixed="true">
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="operand1" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="MyMethodResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Confirmation" maxOccurs="unbounded">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="response" type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MYAPIRequest">
<wsdl:part name="MYAPIRequestPart" element="tns:MyMethod"/>
</wsdl:message>
<wsdl:message name="MYAPIResponse">
<wsdl:part name="MYAPIResponsePart" element="tns:MyMethodResponse"/>
</wsdl:message>
<wsdl:portType name="MYAPIServerPort">
<wsdl:operation name="MyMethod">
<wsdl:input name="MyMethodInput" message="tns:MYAPIRequest"/>
<wsdl:output name="MyMethodOutput" message="tns:MYAPIResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MYAPIServerBinding" type="tns:MYAPIServerPort">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="MyMethod">
<soap12:operation style="document" soapAction="urn:APISoapServer#MyMethod" />
<wsdl:input name="MyMethodInput">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="MyMethodOutput">
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MYAPIService">
<wsdl:port name="MYAPIPort" binding="tns:MYAPIServerBinding">
<soap12:address location="https://my.site.com/api/my_api_server.pl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am trying to integrate WSO2 with Mule. I have taken the WSDL from cxf-services-ws-discovery-api.jar under the org\apache\cxf\ws\discovery\wsdl folder and put it into SOAP UI and hit the URL on localhost port 9443 and it works fine. However, when I add the WSDL to my Mule project and generate the client stub using cxf-codegen-plugin and run it I get the following error;
ERROR 2014-10-08 16:25:31,545 [main] com.deic.RegistryLifecycle: Trace:
javax.xml.ws.WebServiceException: #Action and #WebMethod(action="" does not match on operation probeOp
at com.sun.xml.ws.model.JavaMethodImpl.setWsaActions(JavaMethodImpl.java:124)
at com.sun.xml.ws.model.JavaMethodImpl.<init>(JavaMethodImpl.java:102)
at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:664)
at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:506)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:337)
at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:102)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:75)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:59)
at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:128)
at com.sun.xml.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:803)
at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:810)
at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:786)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:407)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:384)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:366)
at javax.xml.ws.Service.getPort(Unknown Source)
at org.oasis_open.docs.ws_dd.ns.discovery._2009._01.Discovery.getDiscoveryProxy(Discovery.java:79)
at com.deic.RegistryManager.getDiscoveryProxyPort(RegistryManager.java:29)
at com.deic.RegistryManager.getEndoint(RegistryManager.java:35)
at com.deic.RegistryLifecycle.start(RegistryLifecycle.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:237)
at org.mule.lifecycle.RegistryLifecycleManager$RegistryLifecycleCallback.onTransition(RegistryLifecycleManager.java:273)
at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:152)
at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:123)
at org.mule.registry.AbstractRegistryBroker.fireLifecycle(AbstractRegistryBroker.java:76)
at org.mule.registry.MuleRegistryHelper.fireLifecycle(MuleRegistryHelper.java:136)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:91)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:87)
at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(MuleContextLifecycleManager.java:69)
at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(MuleContextLifecycleManager.java:61)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:278)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:123)
at org.mule.module.launcher.artifact.ArtifactWrapper$4.execute(ArtifactWrapper.java:98)
at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129)
at org.mule.module.launcher.artifact.ArtifactWrapper.start(ArtifactWrapper.java:93)
at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:26)
at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:310)
at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:330)
at org.mule.module.launcher.DefaultArchiveDeployer.deployExplodedApp(DefaultArchiveDeployer.java:297)
at org.mule.module.launcher.DefaultArchiveDeployer.deployExplodedArtifact(DefaultArchiveDeployer.java:108)
at org.mule.module.launcher.DeploymentDirectoryWatcher.deployExplodedApps(DeploymentDirectoryWatcher.java:290)
at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:151)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:150)
This is the cxf-codegen-plugin;
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.10</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdd-discovery-1.1-wsdl-os.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-noAddressBinding</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
This is the generated class that is blowing up;
#WebService(targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", name = "DiscoveryProxy")
#XmlSeeAlso({ObjectFactory.class, org.apache.cxf.ws.addressing.ObjectFactory.class})
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface DiscoveryProxy {
#Oneway
#Action(input = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello")
#WebMethod(operationName = "HelloOp", action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/HelloOp")
public void helloOp(
#WebParam(partName = "parameters", name = "Hello", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01")
HelloType parameters
);
#WebResult(name = "ProbeMatches", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", partName = "parameters")
#Action(input = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Probe", output = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches")
#WebMethod(operationName = "ProbeOp", action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeOp")
public ProbeMatchesType probeOp(
#WebParam(partName = "parameters", name = "Probe", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01")
ProbeType parameters
);
#Oneway
#Action(input = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Bye")
#WebMethod(operationName = "ByeOp", action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ByeOp")
public void byeOp(
#WebParam(partName = "parameters", name = "Bye", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01")
ByeType parameters
);
#WebResult(name = "ResolveMatches", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", partName = "parameters")
#Action(input = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Resolve", output = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ResolveMatches")
#WebMethod(operationName = "ResolveOp", action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ResolveOp")
public ResolveMatchesType resolveOp(
#WebParam(partName = "parameters", name = "Resolve", targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01")
ResolveType parameters
);
}
I am not sure why SOAP UI has no issue with the WSDL but the client stub does. I tried to use wireshark but not sure how to configure for HTTPS. I googled and googled, but cannot work out what is going wrong with the generation of the class, obviously it has to do with the #Action and #WebMethod generated, but I am not sure what I have to do to fix the WSDL to make it work.
Here is the WSDL;
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"
xmlns:tns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/">
<wsdl:types>
<xs:schema>
<xs:import
namespace="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"
schemaLocation="wsdd-discovery-1.1-schema-os.xsd" />
</xs:schema>
</wsdl:types>
<wsdl:message name="HelloMessage" >
<wsdl:part name="parameters" element="tns:Hello" />
</wsdl:message>
<wsdl:message name="ByeMessage" >
<wsdl:part name="parameters" element="tns:Bye" />
</wsdl:message>
<wsdl:message name="ProbeMessage" >
<wsdl:part name="parameters" element="tns:Probe" />
</wsdl:message>
<wsdl:message name="ProbeMatchMessage" >
<wsdl:part name="parameters" element="tns:ProbeMatches" />
</wsdl:message>
<wsdl:message name="ResolveMessage" >
<wsdl:part name="parameters" element="tns:Resolve" />
</wsdl:message>
<wsdl:message name="ResolveMatchMessage" >
<wsdl:part name="parameters" element="tns:ResolveMatches" />
</wsdl:message>
<wsdl:portType name="DiscoveryProxy">
<wsdl:operation name="HelloOp" >
<wsdl:input message="tns:HelloMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello"
/>
</wsdl:operation>
<wsdl:operation name="ByeOp" >
<wsdl:input message="tns:ByeMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Bye"
/>
</wsdl:operation>
<wsdl:operation name="ProbeOp" >
<wsdl:input message="tns:ProbeMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Probe"
/>
<wsdl:output message="tns:ProbeMatchMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches"
/>
</wsdl:operation>
<wsdl:operation name="ResolveOp" >
<wsdl:input message="tns:ResolveMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Resolve"
/>
<wsdl:output message="tns:ResolveMatchMessage"
wsaw:Action
="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ResolveMatches"
/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DiscoveryProxy" type="tns:DiscoveryProxy">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="HelloOp">
<soap:operation
soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/HelloOp" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="ByeOp">
<soap:operation
soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ByeOp" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="ProbeOp">
<soap:operation
soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeOp" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="ResolveOp">
<soap:operation
soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ResolveOp" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Discovery">
<wsdl:port name="DiscoveryUDP" binding="tns:DiscoveryProxy">
<soap:address location="soap.udp://:9443"/>
</wsdl:port>
<wsdl:port name="DiscoveryProxy" binding="tns:DiscoveryProxy">
<soap:address location="${discovery_proxy_url}"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The only thing I modified on the WSDL was the soap:address on the wsdl:service. The exception is thrown in the following code when it calls getDiscoveryProxy();
Discovery service = new Discovery();
DiscoveryProxy port = service.getDiscoveryProxy();
I appreciate any help or advice you can give. Thanks!
I found the issue, the #Action(input = "url") needs to match the #WebMethod(action = "url"), it appears that the wsdl from the apache libs has them as different url values.
I came here because I had a similar issue creating a stub from a WSDL describing a Web Service I am integrating into a Java application, and your auto-answer helped me point out the issue.
To fix the issue, you have to manually edit the WSDL and then re-create the client stub.
For each operation, make the wsamAction property's URL the same as soapAction property's URL:
<operation name="operationName">
<input message="xxx" wsam:Action="http://your.name.space/operationName">
</input>
.
.
.
</operation>
same as
<operation name="operationName">
<soap:operation soapAction="http://your.name.space/operationName" />
.
.
.
</operation>
Then re-create the client stub. It should work seamlessly now.
Hope this helps.
I have a simple scenario we've been trying to implement but we could not figure out how to do it.
Assume we have two services with the dame WSDL (below).
We want to create a proxy in WSO2 that exposes the same WSDL but routes the call to one of the two backend services based on the value of the IntValue.
IF IntValue = 1 THEN it calls
http://localhost/WcfServiceDual_1/Service1.svc
ELSE IF IntValue = 2 THEN it calls
http://localhost/WcfServiceDual_2/Service1.svc
After that the proxy returns the response that comes from the corresponding (called) service.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="Service1" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost/WcfServiceDual_2/Service1.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost/WcfServiceDual_2/Service1.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://localhost/WcfServiceDual_2/Service1.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/WcfServiceDual_2"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IService1_GetData_InputMessage">
<wsdl:part name="parameters" element="tns:GetData"/>
</wsdl:message>
<wsdl:message name="IService1_GetData_OutputMessage">
<wsdl:part name="parameters" element="tns:GetDataResponse"/>
</wsdl:message>
<wsdl:message name="IService1_GetDataUsingDataContract_InputMessage">
<wsdl:part name="parameters" element="tns:GetDataUsingDataContract"/>
</wsdl:message>
<wsdl:message name="IService1_GetDataUsingDataContract_OutputMessage">
<wsdl:part name="parameters" element="tns:GetDataUsingDataContractResponse"/>
</wsdl:message>
<wsdl:portType name="IService1">
<wsdl:operation name="GetData">
<wsdl:input wsaw:Action="http://tempuri.org/IService1/GetData" message="tns:IService1_GetData_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IService1/GetDataResponse" message="tns:IService1_GetData_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="GetDataUsingDataContract">
<wsdl:input wsaw:Action="http://tempuri.org/IService1/GetDataUsingDataContract" message="tns:IService1_GetDataUsingDataContract_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IService1/GetDataUsingDataContractResponse" message="tns:IService1_GetDataUsingDataContract_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IService1" type="tns:IService1">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetData">
<soap:operation soapAction="http://tempuri.org/IService1/GetData" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetDataUsingDataContract">
<soap:operation soapAction="http://tempuri.org/IService1/GetDataUsingDataContract" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service1">
<wsdl:port name="BasicHttpBinding_IService1" binding="tns:BasicHttpBinding_IService1">
<soap:address location="http://localhost/WcfServiceDual_2/Service1.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Why you are hosting two instances of the same service ?
Anyway the logic you plan to have in the proxy is very simple. From the incoming request just extarct the param which you want to evaluate and based on that route the request to the differnt endpoint. You can use the filter mediator for this.
I found the solution:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="DualTest" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="custom" separator=",">
<property name="MessageFlow" value="______"/>
</log>
<property xmlns:xs="http://schemas.datacontract.org/2004/07/WcfServiceDual_1" xmlns:p="http://tempuri.org/" name="intValue" expression="//p:GetDataUsingDataContract/p:composite/xs:IntValue/text()" scope="default" type="STRING"/>
<property xmlns:xs="http://schemas.datacontract.org/2004/07/WcfServiceDual_1" xmlns:p="http://tempuri.org/" name="stringValue" expression="//p:GetDataUsingDataContract/p:composite/xs:StringValue/text()" scope="default" type="STRING"/>
<log level="custom">
<property name="intValue" expression="$ctx:intValue"/>
<property name="stringValue" expression="$ctx:stringValue"/>
</log>
<log level="custom" separator=",">
<property name="MessageFlow" value="______"/>
<property name="MessageFlow" value="\n======================= Sending Request To : Backend ======================="/>
</log>
<log level="full" separator=","/>
<filter source="get-property('intValue')" regex="2">
<then>
<log level="custom" separator=",">
<property name="IF" value="***** 2"/>
</log>
<send>
<endpoint>
<address uri="http://Win8/WcfServiceDual_2/Service1.svc"/>
</endpoint>
</send>
</then>
<else>
<log level="custom" separator=",">
<property name="ELSE" value="***** 1"/>
</log>
<send>
<endpoint>
<address uri="http://Win8/WcfServiceDual_1/Service1.svc"/>
</endpoint>
</send>
</else>
</filter>
<log level="custom" separator=",">
<property name="MessageFlow" value="______"/>
</log>
</inSequence>
</target>
<publishWSDL uri="http://localhost/WcfServiceDual_1/Service1.svc?wsdl"/>
<description></description>
</proxy>
I am new to web services, I bought a book and started to learn from it, the WSDL is :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ttdev.com/ss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SimpleService" targetNamespace="http://ttdev.com/ss">
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:element name="concatRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="s1" type="xsd:string" />
<xsd:element name="s2" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="concatResponse" type="xsd:string">
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="concatRequest">
<wsdl:part element="tns:concatRequest" name="parameters"/>
</wsdl:message>
<wsdl:message name="concatResponse">
<wsdl:part element="tns:concatResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="concat">
<wsdl:input message="tns:concatRequest"/>
<wsdl:output message="tns:concatResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSOAP" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="concat">
<soap:operation soapAction="http://ttdev.com/ss/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<wsdl:port binding="tns:SimpleServiceSOAP" name="p1">
<soap:address location="http://localhost:8080/ss/p1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I run the SimpleService_P1_Server, it s working, but when I run the client :
SimpleService_P1_Client I got this exeption :
Apr 8, 2012 9:51:47 AM com.ttdev.ss.SimpleService_Service <clinit>
INFO: Can not initialize the default wsdl from src/main/resources/SimpleService.wsdl
Exception in thread "main" javax.xml.ws.WebServiceException: Port {http://ttdev.com/ss}p1 not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:328)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.ttdev.ss.SimpleService_Service.getP1(SimpleService_Service.java:56)
at com.ttdev.ss.SimpleService_P1_Client.main(SimpleService_P1_Client.java:49)
Thanks, your help is appreciated.
I also faced similar issue some time back. You may want to use a prefix "file:" before "src/main/resources". Here is the resultant code:
WSDLToJava.main(new String[] { "-client", "-d", "src/main/java",
"file:src/main/resources/SimpleService.wsdl" });
I've been experiencing some issues with the header presentation of a SOAP Request. I think I'm missing something.
My (partial) wsdl looks like this:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:aws="http://xml.xxx.com"
xmlns:security_authenticate_6_1="http://xml.xxx.com/VLSSLQ_06_1_1A"
xmlns:security_authenticatereply_6_1="http://xml.xxx.com/VLSSLR_06_1_1A"
targetNamespace="http://xml.xxx.com">
<wsdl:types>
<xsd:schema targetNamespace="http://xml.xxx.com">
<xsd:import namespace="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd" schemaLocation="WBS_Session-2.0.xsd"/>
<xsd:import namespace="http://xml.xxx.com/VLSSLQ_06_1_1A" schemaLocation="Security_Authenticate_06_1_1A.xsd"/>
<xsd:import namespace="http://xml.xxx.com/VLSSLR_06_1_1A" schemaLocation="Security_AuthenticateReply_06_1_1A.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="Session" xmlns:ns0="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd">
<wsdl:part name="Session" element="ns0:Session"/>
</wsdl:message>
<wsdl:message name="Security_Authenticate_6_1">
<wsdl:part name="Security_Authenticate_6_1" element="security_authenticate_6_1:Security_Authenticate"/>
</wsdl:message>
<wsdl:message name="Security_AuthenticateReply_6_1">
<wsdl:part name="Security_AuthenticateReply_6_1" element="security_authenticatereply_6_1:Security_AuthenticateReply"/>
</wsdl:message>
<wsdl:portType name="XXXWebServicesPT">
<wsdl:operation name="Security_Authenticate">
<wsdl:input message="aws:Security_Authenticate_6_1"/>
<wsdl:output message="aws:Security_AuthenticateReply_6_1"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="XXXWebServicesBinding" type="aws:XXXWebServicesPT">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Security_Authenticate">
<soap:operation soapAction="http://webservices.xxx.com/1ASIWJTUTUA/VLSSLQ_06_1_1A"/>
<wsdl:input>
<soap:header message="aws:Session" part="Session" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:header message="aws:Session" part="Session" use="literal"/>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="XXXWebServices">
<wsdl:port name="XXXWebServicesPort" binding="aws:XXXWebServicesBinding">
<soap:address location="https://test.webservices.xxx.com"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I want to access the Security_Authenticate action, in which case, the header must look something like:
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
<soapenv:Header>
<wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
<wbs:SessionId></wbs:SessionId>
<wbs:SequenceNumber></wbs:SequenceNumber>
<wbs:SecurityToken></wbs:SecurityToken>
</wbs:Session>
</soapenv:Header>
<soapenv:Body>
<vls:Security_Authenticate>
<vls:tagX>
<vls:tagY>yyy</vls:tagY>
<vls:tagZ>Z</vls:tagZ>
</vls:tagX>
</vls:Security_Authenticate>
</soapenv:Body>
</soapenv:Envelope>
How should I built my soapenvelope and my header namespaces?
Thanks.
You have to declare the namespace before you use the object in the xsd, so in your case, to use the Session object:
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
<soapenv:Header>
<wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
<wbs:SessionId></wbs:SessionId>
<wbs:SequenceNumber></wbs:SequenceNumber>
<wbs:SecurityToken></wbs:SecurityToken>
</wbs:Session>
</soapenv:Header>
...