There is no encoding style URI defined for the SOAP body - web-services

In one of the wsdl, I am getting this build error (eclipse IDE - Eclipse Java EE IDE for Web Developers - Photon 4.8.0).
There is no encoding style URI defined for the SOAP body. You must specify at least one URI for the encoding style when the use is encoded.
<operation name="getIdNoRestrict">
<soap:operation soapAction=""/>
<input>
<soap:body use="encoded" namespace="http://webservices.document.pv4a.com/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://webservices.document.pv4a.com/"/>
</output>
</operation>
XML definition is:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="DocWebSer"
targetNamespace="http://webservices.document.pv4a.com/"
xmlns:tns="http://webservices.document.pv4a.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
Even after adding an encodingStyle attribute, this error still would not go.
Working with JDK 1.8

Related

SOAPUI error: does not close tag

When starting a SOAPUI SOAP project (from my local computer) using the following URL (on a server in my own network):
http://myinternaldomainname/test2?wsdl
The following error occurs:
Error loading [http://myinternaldomainname/test2?wsdl]:
org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException:
error: does not close tag
The server is added to my hosts file:
192.168.2.1 myexampledomain
When I store the result of the WSDL page as a wsdl file, I can open the WSDL file as new SOAP project.
I used Zend\Soap\Autodiscovery to generate this WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://myexampledomain/test2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="MySoapService" targetNamespace="http://myexampledomain/test2">
<types>
<xsd:schema targetNamespace="http://myexampledomain/test2"/>
</types>
<portType name="MySoapServicePort">
<operation name="method1">
<documentation>This method takes ...</documentation>
<input message="tns:method1In"/>
<output message="tns:method1Out"/>
</operation>
<operation name="method2">
<documentation>This method takes ...</documentation>
<input message="tns:method2In"/>
<output message="tns:method2Out"/>
</operation>
</portType>
<binding name="MySoapServiceBinding" type="tns:MySoapServicePort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="method1">
<soap:operation soapAction="http://myexampledomain/test2#method1"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://myexampledomain/test2"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://myexampledomain/test2"/>
</output>
</operation>
<operation name="method2">
<soap:operation soapAction="http://myexampledomain/test2#method2"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://myexampledomain/test2"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://myexampledomain/test2"/>
</output>
</operation>
</binding>
<service name="MySoapServiceService">
<port name="MySoapServicePort" binding="tns:MySoapServiceBinding">
<soap:address location="http://myexampledomain/test2"/>
</port>
</service>
<message name="method1In">
<part name="inputParam" type="xsd:int"/>
</message>
<message name="method1Out">
<part name="return" type="xsd:string"/>
</message>
<message name="method2In">
<part name="inputParam1" type="xsd:int"/>
<part name="inputParam2" type="xsd:string"/>
</message>
<message name="method2Out">
<part name="return" type="xsd:float"/>
</message>
</definitions>
In SOAPUI I tried proxy disabled/enabled/automatic
If someone ever encounters this problem, what worked for me was hitting CTRL + ALT + P and setting the Proxy Settings to None
Please disable proxy by using CTRL+ALT+P and disable system firewall. hopefully it will work.
The problem was caused because a login page prevented me to use the WSDL in SOAP UI.

Couldn't find <definitions> in WSDL

i tried to develop my first SOAP webservice, but i'm stuck with an error when i try to open my WSDL with wizdl. I got this error :
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>WSDL</faultcode>
<faultstring>
SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in
'http://localhost/testSolution/test.wsdl'
</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Here is my code : testSolution.php :
<?php
class Ws{
function getString()
{
return "TESTASTOS";
}
}
ini_set("soap.wsdl_cache_enabled", 0);
$serversoap = new SoapServer("http://localhost/testSolution/test.wsdl");
$serversoap->setClass("Ws");
$serversoap->handle();
?>
And test.wsdl :
<?xml version="1.0" encoding="iso-8859-1"?>
<definitions
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl"
targetNamespace="urn:serviceTestwsdl"
xmlns:tns="urn:serviceTestwsdl"
>
<types>
<xsd:schema targetNamespace="urn:serviceTestwsdl"/>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
</types>
<message name="getStringRequest">
</message>
<message name="getStringResponse">
<part name="return" type="xsd:string" />
</message>
<portType name="serviceTestPortType">
<operation name="getString">
<documentation>Récupère un string</documentation>
<input message="tns:getStringRequest"/>
<output message="tns:getStringResponse"/>
</operation>
</portType>
<binding name="serviceTestBinding" type="tns:serviceTestPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getString">
<soap:operation soapAction="urn:serviceTestwsdl#getString" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:serviceTestwsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:serviceTestwsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="serviceTest">
<port name="serviceTestPort" binding="tns:serviceTestBinding">
<soap:address location="http://localhost/testSolution/testSolution.php"/>
</port>
</service>
</definitions>
The mainly goal is to understand how a soap webservice work by making a small hello world on string.
Thanks a lot for your Help
Regards. Didier
You need to add the "wsdl" prefix like <wsdl:definitions> in the test.wsdl. Also to the first level of elements within that param:
<wsdl:types>...</wsdl:types>
<wsdl:operation>...</wsdl:operation>
... etc
This will allow you to load the wsdl.

java.lang.ClassCastException: org.jboss.ws.core.soap.TextImpl cannot be cast to javax.xml.soap.SOAPElement

I am working on IBM Sterling V 9.3. I have exposed an Service as JAX-WS web service using the steps provided in the knowledge center successfully on Jboss 4.2.3 app server. EAR file got deployed successfully and app server started fine. I could see the generated WSDL file for the web service.
When I tried to access the WSDL from soapUI tool (version 3.5.1), I am getting the following error in the response message. I searched for the same and found out that we should have following jars under JBOSS_HOME\lib\endorsed folder:
• jboss-saaj.jar
• jboss-jaxws.jar
• jboss-jaxrpc.jar
• jaxb-api-2.1.9.jar
• xercesImpl.jar
• xalan.jar
• serializer.jar
I have added above jars but still getting the same error. Can share the more details if required. Please help.
Error message:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>java.lang.ClassCastException: org.jboss.ws.core.soap.TextImpl cannot be cast to javax.xml.soap.SOAPElement</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="SearsBeansService"
targetNamespace="http://webservices.sears.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://webservices.sears.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema>
<xsd:import
namespace="http://webservices.sears.com/documentation/SearsGetOrderListForWSCService/searsGetOrderListForWSCService/output" schemaLocation="SearsBeansService_schema1.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import
namespace="http://webservices.sears.com/documentation/SearsGetOrderListForWSCService/searsGetOrderListForWSCService/input" schemaLocation="SearsBeansService_schema2.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import
namespace="http://webservices.sears.com/documentation/SearsGetOrderDetailsForWSCService/searsGetOrderDetailsForWSCService/output" schemaLocation="SearsBeansService_schema3.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import
namespace="http://webservices.sears.com/documentation/SearsGetOrderDetailsForWSCService/searsGetOrderDetailsForWSCService/input" schemaLocation="SearsBeansService_schema4.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://webservices.sears.com/" schemaLocation="SearsBeansService_schema5.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import
namespace="http://www.sterlingcommerce.com/documentation/types" schemaLocation="yfctype.xsd"/>
</xsd:schema>
</types>
<message name="searsGetOrderDetailsForWSCService">
<part element="tns:searsGetOrderDetailsForWSCService" name="parameters"/>
</message>
<message name="searsGetOrderDetailsForWSCServiceResponse">
<part element="tns:searsGetOrderDetailsForWSCServiceResponse" name="parameters"/>
</message>
<message name="XBeanWSException">
<part element="tns:XBeanWSException" name="fault"/>
</message>
<message name="searsGetOrderListForWSCService">
<part element="tns:searsGetOrderListForWSCService" name="parameters"/>
</message>
<message name="searsGetOrderListForWSCServiceResponse">
<part element="tns:searsGetOrderListForWSCServiceResponse" name="parameters"/>
</message>
<portType name="SearsBeans">
<operation name="searsGetOrderDetailsForWSCService">
<input message="tns:searsGetOrderDetailsForWSCService"/>
<output message="tns:searsGetOrderDetailsForWSCServiceResponse"/>
<fault message="tns:XBeanWSException" name="XBeanWSException"/>
</operation>
<operation name="searsGetOrderListForWSCService">
<input message="tns:searsGetOrderListForWSCService"/>
<output message="tns:searsGetOrderListForWSCServiceResponse"/>
<fault message="tns:XBeanWSException" name="XBeanWSException"/>
</operation>
</portType>
<binding name="SearsBeansPortBinding" type="tns:SearsBeans">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="searsGetOrderDetailsForWSCService">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="XBeanWSException">
<soap:fault name="XBeanWSException" use="literal"/>
</fault>
</operation>
<operation name="searsGetOrderListForWSCService">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="XBeanWSException">
<soap:fault name="XBeanWSException" use="literal"/>
</fault>
</operation>
</binding>
<service name="SearsBeansService">
<port binding="tns:SearsBeansPortBinding" name="SearsBeansPort">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
I am able to resolve this issue. I had to remove all the white spaces, comments and question marks (?) from the request (if any).
After that it was working fine. I think, due to the white spaces in request, soapUI was treating it as some kind of request element/value and was unable to convert into SOAPElement.
Hope this would be helpful for others !
Under Request Properties, set "Strip whitespaces" to true. This must be done for each new request. I didn't find a way to set true by default.
Questions marks are placeholders for parameters that must be supplied in your request.

Deploy .war developed in jdeveloper on glassfish4.0

I developed a .war file in jdeveloper 10.1.3. And I want to deploy it on glassfish4.0 server which is standalone server.
Firstly I write a java code as
package com.oi.testdemohello;
public class TestHello {
public TestHello() {
}
public String sayHello(String name){
return "Hello "+name;
}
}
Than I create a J2EE1.4(JAX-RPC) and SOAP 1.1 Binding web services from that code in jdeveloper which statefull service.
The WSDL generated is as :
<definitions
name="MyWebService"
targetNamespace="http://testdemohello.oi.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://testdemohello.oi.com/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns0="http://testdemohello.oi.com/types/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://testdemohello.oi.com/types/"
elementFormDefault="qualified" xmlns:tns="http://testdemohello.oi.com/types/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">
<element name="sayHelloElement">
<complexType>
<sequence>
<element name="name" type="string" nillable="true"/>
</sequence>
</complexType>
</element>
<element name="sayHelloResponseElement">
<complexType>
<sequence>
<element name="result" type="string" nillable="true"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="MyWebService_sayHello">
<part name="parameters" element="tns0:sayHelloElement"/>
</message>
<message name="MyWebService_sayHelloResponse">
<part name="parameters" element="tns0:sayHelloResponseElement"/>
</message>
<portType name="MyWebService">
<operation name="sayHello">
<input message="tns:MyWebService_sayHello"/>
<output message="tns:MyWebService_sayHelloResponse"/>
</operation>
</portType>
<binding name="MyWebServiceSoapHttp" type="tns:MyWebService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="http://testdemohello.oi.com//sayHello"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="MyWebService">
<port name="MyWebServiceSoapHttpPort" binding="tns:MyWebServiceSoapHttp">
<soap:address location="http://localMachine3:8888/TestDemoHello-DemoHello-context-root/MyWebServiceSoapHttpPort"/>
</port>
</service>
Than I deploy a .war file of this.
Now I want to deploy this .war file to glassfish 4.0 server. But I am not able to do it. How to do it please suggest me.
There are different options, outlined for example in this question: Best way to deploy on Glassfish V3. Your easiest option is to use the Glassfish Admin GUI on http://localhost:4848.
If you want something that is integrated in JDeveloper you can try GlassFish Extension for Oracle JDeveloper or read this article and this question.

WSDL Document Literal with parts referencing XSD types

I've been reading WSDL 1.1 specification and there's one thing that seems strange to me - what (beside WS-I Basic Profile) prevents me from doing this:
<message name="helloRequest">
<part name="arg1" type="xs:string" />
</message>
<message name="helloResponse">
<part name="result" type="xs:string" />
</message>
<portType name="Port02">
<operation name="hello">
<input message="tns:helloRequest" name="helloRequest" />
<output message="tns:helloResponse" name="helloResponse" />
</operation>
</portType>
<binding name="Port02SoapBinding" type="tns:Port02">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="hello">
<input name="helloRequest">
<soap:body use="literal" />
</input>
<output name="helloResponse">
<soap:body use="literal" />
</output>
</operation>
</binding>
It's document/literal web service, but in/out messages contain parts which refer to XSD (simple) types, not global elements.
The WSDL fragment is not that scary - Both Axis1 and CXF generate soap body elements which have names derived from part names, but WSDL 1.1, 3.5: soap:body says:
If use is literal, then each part references a concrete schema definition using either the element or type attribute. In the first case, [...]. In the second, the type referenced by the part becomes the schema type of the enclosing element (Body for document style or part accessor element for rpc style).
Does that mean that the resulting SOAP message (according to WSDL specification) will look like this (text content inside SOAP body)?
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xs="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body xsi:type="xs:string">value</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
That's edge case - in practice all java (axis1, axis2, cxf, jaxrpc-ri) implementations I've checked wrap String (or any simple) type with element named after part's name with no namespace.
Axis1:
private static void _initOperationDesc1(){
org.apache.axis.description.OperationDesc oper;
org.apache.axis.description.ParameterDesc param;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("hello");
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "arg1"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
oper.addParameter(param);
oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(new javax.xml.namespace.QName("", "result"));
oper.setStyle(org.apache.axis.constants.Style.DOCUMENT);
oper.setUse(org.apache.axis.constants.Use.LITERAL);
_operations[0] = oper;
}
JAXRPC-RI:
SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_hello_arg1_QNAME);
_bodyBlock.setValue(arg1);
_bodyBlock.setSerializer(ns2_myns2_string__java_lang_String_String_Serializer);
_request.setBody(_bodyBlock);
...
private static final javax.xml.namespace.QName ns1_hello_arg1_QNAME = new QName("", "arg1");
So you should get:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xs="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<arg1>value</arg1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EDIT: Also in WSDL 2.0 there are no messages and operation inputs and outputs must refer to elements (or #any or #none or #other).