Apache CXF WSDLToJava Error: operation already exists. How to bypass? - wsdl

I am developing second client application that is consuming existing SOAP web-services.
I generate Java from existing WSDL using the latest Apache CXF 2.3 tool
wsdl2java -client -ant http://172.20.0.22/someletters/TradingServer.asmx?WSDL
and get
WSDLToJava Error: java.lang.IllegalArgumentException: An operation with name [{urn:someschema:TradingServer}GetTradeSummary] already exists in this service
that has logic, because when looking at WSDL file you can see 2 similar operation GetTradeSummary, but with different soapAction.
<wsdl:operation name="GetTradeSummary">
<soap:operation soapAction="urn:someschema/GetTradeSummary" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetTradeSummary">
<soap:operation soapAction="urn:someschema/GetTradeSummary_Open" style="document" />
<wsdl:input name="GetTradeSummary_Open">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="GetTradeSummary_Open">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
a) Is it really regarded as erroneous by some standard? Which one?
b) Is there way to bypass this and generate Java scaffolding for the rest?
There's nothing such mentioned at CXF WSDL to Java tool web page, except -autoNameResolution which does not help.

This is specifically disallowed by the WSI-Basic Profile. If you look at:
http://www.ws-i.org/profiles/basicprofile-1.1.html
Section 4.5.3, it specifically states:
Operation name overloading in a wsdl:portType is disallowed by the Profile.
I don't think there is a way around it in CXF as the operations are stored in a Map keyed on QName. Since the QNames would not be unique, only one operation can be stored in the map.

Related

References not found in WSDL

I am using JDeveloper 12.2.1.4 for developing OSB services on Windows.
When I add a new REST adapter, I use the wizards to generate schemas for the request and response. Within the Resources folder, I created a Provinces folder and in the wizard step, I select that as the schema location. The XSD files are created within that folder but the WSDL gives errors that it can't find the schemas and the root elements.
The generated WSDL:
<wsdl:definitions name="LocationServices"
targetNamespace="http://xmlns.oracle.com/ServiceBusApplication1/LocationServices/LocationServices"
xmlns:tns="http://xmlns.oracle.com/ServiceBusApplication1/LocationServices/LocationServices"
xmlns:inp1="http://TargetNamespace.com/LocationServices_getProvinces_request"
xmlns:inp2="http://TargetNamespace.com/LocationServices_getProvinces_response"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<plnk:partnerLinkType name="LocationServices">
<plnk:role name="LocationServicesProvider" portType="tns:LocationServices_ptt"/>
</plnk:partnerLinkType>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/LocationServices_getProvinces_request"
schemaLocation="Province-Request.xsd"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/LocationServices_getProvinces_response"
schemaLocation="Province-Response.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getProvinces_inputMessage">
<wsdl:part name="request" element="inp1:Province-Request-Root-Element"/>
</wsdl:message>
<wsdl:message name="getProvinces_outputMessage">
<wsdl:part name="reply" element="inp2:Province-Response-Root-Element"/>
</wsdl:message>
<wsdl:portType name="LocationServices_ptt">
<wsdl:operation name="getProvinces">
<wsdl:input message="tns:getProvinces_inputMessage"/>
<wsdl:output message="tns:getProvinces_outputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LocationServices_ptt-binding" type="tns:LocationServices_ptt">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getProvinces">
<soap:operation soapAction="getProvinces"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
The first error of "The resource mapped does not exist" & "Reference to non-existing instance XMLSchema LocationServices/Resources/Province-Request" gets fixed if I change the line to:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/LocationServices_getProvinces_request"
schemaLocation="**Provinces/**Province-Request.xsd"/>
But the second error of "Reference inp1:Province-Request-Root-Element not found" still remains. Yes, that is the name of the root element in the XSD file.
No where in the source is the folder mentioned, so is the folder named "Resources" a default or something?

How to create a Mule Project v3.8 which redirects messages to an external Web Service?

I would like to create a Mule Project, and the idea is to send a SOAP message (for example through soapUI) to this project, and then, redirect the message to an external web service.
I have read the documentation, I can't figure out how to do this simple task.
I would appreciate if someone could help me. I am using Mule v3.8.
Thanks in advance.
You can use the Web Service Consumer connector as explained at MuleSoft Documentation and Video Tutorial
In general,
You can use:
HTTP endpoint (request-response) ->
CXF component (for you proxy service, optional) ->
Web Service Consumer (to call needed service)
If I'm not very clear, I can help you in building this project.
update
I made a simple service and now we have wsdl:
<wsdl:definitions name="SimpleServiceService" targetNamespace="http://simple/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://simple/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema elementFormDefault="unqualified" targetNamespace="http://simple/" version="1.0" xmlns:tns="http://simple/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="doSomething" type="tns:doSomething"/>
<xs:element name="doSomethingResponse" type="tns:doSomethingResponse"/>
<xs:complexType name="doSomething">
<xs:sequence>
<xs:element minOccurs="0" name="Input" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="doSomethingResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="doSomethingResponse">
<wsdl:part element="tns:doSomethingResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="doSomething">
<wsdl:part element="tns:doSomething" name="parameters"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="doSomething">
<wsdl:input message="tns:doSomething" name="doSomething"/>
<wsdl:output message="tns:doSomethingResponse" name="doSomethingResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceServiceSoapBinding" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="doSomething">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="doSomething">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="doSomethingResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleServiceService">
<wsdl:port binding="tns:SimpleServiceServiceSoapBinding" name="SimpleServicePort">
<soap:address location="http://exoldy-simple-mule-project.cloudhub.io/service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Next we need to interact with this service using proxy service implemented on Mule
<mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
<ws:consumer-config name="Web_Service_Consumer" service="SimpleServiceService" port="SimpleServicePort" serviceAddress="http://exoldy-simple-mule-project.cloudhub.io/service" wsdlLocation="http://exoldy-simple-mule-project.cloudhub.io/service?wsdl" doc:name="Web Service Consumer"/>
<http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="external" initialState="started">
<http:listener config-ref="HTTP_Listener_Configuration1" path="service" doc:name="Receive HTTP request" doc:description="This endpoint receives an HTTP message."/>
<logger message="#[flow.name]" level="INFO" doc:name="Logger"/>
<cxf:proxy-service payload="body" doc:name="CXF" namespace="http://simple/" service="SimpleServiceService" wsdlLocation="http://exoldy-simple-mule-project.cloudhub.io/service?wsdl"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="doSomething" doc:name="Web Service Consumer"/>
</flow>
</mule>
Now everything should work, at least it works for me )

How to use the wsdl in wso2esb with addition operation

I am using wso2esb4.7.0, I tried with database working fine I wrote the proxyies without publish wsdl option so those working fine .There is no operations publishing that is fine.
Now I wish to publish the operation, for that I wrote a sample wsdl and I place it in my local system downloads folder. When I am importing into proxy its unable to import, if I give any wso2dss wsdl with this url:192.168.1.14:8282/services/user?wsdl the service is working fine and publishing operations also but I dont want to use that wso2dss opeartions, I wish publish my own operation how could I do this
my wsdl file like this
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/Addition.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/Addition.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="SayHelloRequest">
<part name="var1" type="xsd:integer"/>
<part name="var2" type="xsd:integer"/>
</message>
<message name="SayHelloResponse">
<part name="result" type="xsd:integer"/>
</message>
<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://www.examples.com/SayHello/">
</port>
</service>
and I am storing this into this path
home/downloads/system/addtion.wsdl
but its not importing its giving errors
where can I store this wsdl for importing into wso2esb

IllegalArgumentException: key can't be empty -- Which Key?

Trying to build a demo contract-first service from a sample WSDL (using CXF 2.7.1):
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="OrderProcessService" targetNamespace="http://order.demo/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://order.demo/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://order.demo/" xmlns:tns="http://order.demo/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="processOrder" type="tns:processOrder" />
<xs:element name="processOrderResponse" type="tns:processOrderResponse" />
<xs:complexType name="processOrder">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:order" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="order">
<xs:sequence>
<xs:element minOccurs="0" name="customerID" type="xs:string" />
<xs:element minOccurs="0" name="itemID" type="xs:string" />
<xs:element name="price" type="xs:double" />
<xs:element name="qty" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="processOrderResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="processOrderResponse">
<wsdl:part element="tns:processOrderResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="processOrder">
<wsdl:part element="tns:processOrder" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="OrderProcess">
<wsdl:operation name="processOrder">
<wsdl:input message="tns:processOrder" name="processOrder">
</wsdl:input>
<wsdl:output message="tns:processOrderResponse" name="processOrderResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderProcessServiceSoapBinding" type="tns:OrderProcess">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="processOrder">
<soap:operation soapAction="" style="document" />
<wsdl:input name="processOrder">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="processOrderResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderProcessService">
<wsdl:port binding="tns:OrderProcessServiceSoapBinding" name="OrderProcessPort">
<soap:address location="http://localhost:8080/OrderProcess" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I issued the following:
wsdl2java -ant -impl -server -d src OrderProcess.wsdl
Source code generation goes fine but when I try to build the server, using ant OrderProcessServer, I receive the following exception:
OrderProcessServer:
[java] Starting Server
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at org.eclipse.jetty.util.component.AbstractLifeCycle.<clinit>(AbstractLifeCycle.java:33)
[java] at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.activate(JettyHTTPDestination.java:178)
[java] at org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:48)
[java] at org.apache.cxf.binding.AbstractBaseBindingFactory.addListener(AbstractBaseBindingFactory.java:95)
[java] at org.apache.cxf.binding.soap.SoapBindingFactory.addListener(SoapBindingFactory.java:895)
[java] at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:131)
[java] at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:360)
[java] at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
[java] at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:152)
[java] at javax.xml.ws.Endpoint.publish(Endpoint.java:57)
[java] at demo.order.OrderProcess_OrderProcessPort_Server.<init>(OrderProcess_OrderProcessPort_Server.java:19)
[java] at demo.order.OrderProcess_OrderProcessPort_Server.main(OrderProcess_OrderProcessPort_Server.java:23)
[java] Caused by: java.lang.IllegalArgumentException: key can't be empty
[java] at java.lang.System.checkKey(System.java:774)
[java] at java.lang.System.getProperty(System.java:647)
[java] at org.eclipse.jetty.util.log.Log$1.run(Log.java:122)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at org.eclipse.jetty.util.log.Log.<clinit>(Log.java:85)
[java] ... 12 more
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds
My questions are:
What key?
How do provide it so that I don't get the exception?
Why is wsdl2java producing code that is incomplete? (i.e. isn't the .wsdl file sufficient?)
UPDATE: The ANT build.xml file produced by the wsdl2java command has these 2 seemingly relevant lines:
<sysproperty key="java.util.logging.config.file" value="${cxf.etc.dir}/logging.properties"/>
<sysproperty key="log4j.configuration" value="file:///${cxf.etc.dir}/log4j.properties"/>
Are they key (no pun intended) to the problem?
If so, what values should I put there in order to fix it?
How do I tell wsdl2java to generate code that I don't need to fix?
Jetty's Log implementation is reading the system properties like this:
Enumeration<String> systemKeyEnum = Enumeration<String>)System.getProperties().propertyNames();
while (systemKeyEnum.hasMoreElements())
{
String key = systemKeyEnum.nextElement();
String val = System.getProperty(key);
// ... (process key/values)
}
For some reason you have managed to have an empty key: "" in your System properties. So check all the places where you set System Properties programmatically (System.setProperty) and your java commandline for -D options.
If that doesn't help, try to print your system properties before this exception occurs or do a jpda debug session and place a breakpoint either at Log line <122 or at System.checkKey().
The empty keys come from the cxfrun macro in the generated ant script, build.xml.
Comment it out like so and you should be fine:
<arg value="#{param1}"/>
<arg value="#{param2}"/>
<arg value="#{param3}"/>
<arg value="#{param4}"/>
<arg value="#{param5}"/>
<jvmarg value="${cxf.endorsed.flag}"/>
<!-- Commented out to remove empty keys in system properties -->
<!-- jvmarg value="#{jvmarg1}"/>
<jvmarg value="#{jvmarg2}"/>
<jvmarg value="#{jvmarg3}"/>
<jvmarg value="#{jvmarg4}"/>
<jvmarg value="#{jvmarg5}"/ -->
The empty key can also come from "comments", of this type:
=====================================
This line above may have been marked as a comment, but the system is going to think of the equals sign as a key value marker.

WCF Timeout issue?

I have a somewhat long-taking WCF-based process. WCF service runs in Azure if its of any help. The issue I believe has to do with timeouts:
1) Winforms client has the following .config setting in the binding section:
<wsHttpBinding>
<binding name="XXX" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="255" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
2) WCF service has the following binding section in the web.config
<wsHttpBinding>
<binding name="XXX" maxReceivedMessageSize="10000000" sendTimeout="00:10:00" receiveTimeout="00:10:00" closeTimeout="00:10:00" openTimeout="00:10:00">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
<readerQuotas maxArrayLength="2000000" maxBytesPerRead="10000000" maxStringContentLength="10000000" maxDepth="255" />
</binding>
</wsHttpBinding>
3) I have one long-running method in WCF (generally 2 minutes). Clients call the method, and those that execute for longer then 1 minute are getting thrown out with an exception. This is the most inner exception:
<InnerException>
<Type>System.Net.Sockets.SocketException</Type>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
<Frame>at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</Frame>
</StackTrace>
</InnerException>
</InnerException>
4) The WCF call itself completed successfully, however (I have both Start/End logged on server side). How do I avoid the exception?
Thank you!
The Windows Azure load balancer terminates idle connections after 60 seconds.
Check out the latest post from Azure team... http://azure.microsoft.com/blog/2014/08/14/new-configurable-idle-timeout-for-azure-load-balancer/
Updated answer:
Azure load balancer terminates idle connections after 4 minutes. If you're interested in increasing/decreasing timeout value, check this article:
https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/

Resources