How to built SOAP Header namespaces based on the WSDL file - soap

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>
...

Related

How to have a wsdl conform to the soap input

We are changing our soap webservices from jetty to jaxws. The goal is to keep the same input message. I have used the original WSDL to create the service with netbeans. The WSDL is the following:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
<xs:complexType name="DcxExpeditie">
<xs:sequence>
<xs:element name="Expeditie" type="tns:Expeditie"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Expeditie">
<xs:sequence>
<xs:element name="tag1" type="xs:string"/>
<xs:element name="tag2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="DcxExpeditieRequest">
<wsdl:part name="DcxExpeditie" type="tns:DcxExpeditie"/>
</wsdl:message>
<wsdl:message name="DcxExpeditieResponse">
<wsdl:part name="DcxExpeditieResponse" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="DcxExpeditieServicePortType">
<wsdl:operation name="DcxExpeditieOperation">
<wsdl:input message="tns:DcxExpeditieRequest"/>
<wsdl:output message="tns:DcxExpeditieResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DcxExpeditieOperation">
<soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
<wsdl:input>
<soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DcxExpeditieService">
<wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
<soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
When using this WSDL in soapui it results in the following input example:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:DcxExpeditieOperation>
<DcxExpeditie>
<v1:Expeditie>
<v1:tag1>?</v1:tag1>
<v1:tag2>?</v1:tag2>
</v1:Expeditie>
</DcxExpeditie>
</v1:DcxExpeditieOperation>
</soapenv:Body>
</soapenv:Envelope>
However, the original input format was:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:DcxExpeditie>
<v1:Expeditie>
<v1:tag1>?</v1:tag1>
<v1:tag2>?</v1:tag2>
</v1:Expeditie>
</v1:DcxExpeditie>
</soapenv:Body>
</soapenv:Envelope>
so with no DcxExpeditieOperation tag and with the v1 namespace in front of DcxExpeditie
Is this possible and if so, how can I accomplish this?
Try to change SOAP binding from rpc to document to remove DcxExpeditieOperation tag:
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
To fix the namespace issue refer DcxExpeditie element insted of type:
<wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
Updated WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
<xs:element name="DcxExpeditieResponse" type="xs:string"/>
<xs:complexType name="DcxExpeditie">
<xs:sequence>
<xs:element name="Expeditie" type="tns:Expeditie"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Expeditie">
<xs:sequence>
<xs:element name="tag1" type="xs:string"/>
<xs:element name="tag2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="DcxExpeditieRequest">
<wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
</wsdl:message>
<wsdl:message name="DcxExpeditieResponse">
<wsdl:part name="DcxExpeditieResponse" element="tns:DcxExpeditieResponse" />
</wsdl:message>
<wsdl:portType name="DcxExpeditieServicePortType">
<wsdl:operation name="DcxExpeditieOperation">
<wsdl:input message="tns:DcxExpeditieRequest"/>
<wsdl:output message="tns:DcxExpeditieResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DcxExpeditieOperation">
<soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DcxExpeditieService">
<wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
<soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Wsdl webservice with matlab

I'm trying to use the function "createClassFromWsdl" with matlab and it gives me a error :
createClassFromWsdl('http://localhost/soapserver/server.php?WSDL')
Retrieving document at 'http://localhost/soapserver/server.php?WSDL'
Struct contents reference from a non-struct array object.
Error in createClassFromWsdl>parseWsdl (line 74)
se = defTypes.getExtensibilityElements().get(0);
Error in createClassFromWsdl (line 34)
[R, schema] = parseWsdl(wsdlUrl);
I have download a software called SOAPUI which works perfectly well so I can't found what is wrong...
Here is my simple wsdl file :
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://localhost/soapserver" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://localhost/soapserver">
<wsdl:message name="printtxtSoapIn">
<wsdl:part name="txt" type="s:string"/>
</wsdl:message>
<wsdl:message name="printtxtSoapOut">
<wsdl:part name="return" type="s:string"/>
</wsdl:message>
<wsdl:portType name="SoapDemoSoap">
<wsdl:operation name="printtxt">
<wsdl:input message="tns:printtxtSoapIn"/>
<wsdl:output message="tns:printtxtSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SoapDemoSoap" type="tns:SoapDemoSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<wsdl:operation name="printtxt">
<soap:operation soapAction="http://localhost/soapserver/printtxt"/>
<wsdl:input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/soapserver" parts="txt"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/soapserver" parts="return"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SoapDemo">
<wsdl:port name="SoapDemoSoap" binding="tns:SoapDemoSoap">
<soap:address location="http://localhost/soapserver/server.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

WSO2 Integration

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.

WSO2: SOAP services routing based on an method param

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>

Web Services Port {http://ttdev.com/ss}p1 not found

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" });