Method name in soap message request - java

I have an interesting problem, I'm using SOAP UI to parse the WSDL. The WSDL from payPal
https://developer.paypal.com/docs/classic/api/PayPalSOAPAPIArchitecture/
When I try to load it in SOAP UI, all the method names are getting created that's fine, but when I look into the Messages, The method name in tree view is BillOutstandingAmount But when I open the request
<soapenv:Body>
<urn:BillOutstandingAmountReq>
....
</urn:BillOutstandingAmountReq>
</soapenv:Body>
How the method name in SOAP request can be changed.? Is there any annotation to do so? When I look into the WSDL,
<wsdl:message name="BillOutstandingAmountRequest">
<wsdl:part name="BillOutstandingAmountRequest" element="ns:BillOutstandingAmountReq"/>
</wsdl:message>
The operation part of WSDL
<wsdl:operation name="BillOutstandingAmount">
<wsdl:input message="ns:BillOutstandingAmountRequest"/>
<wsdl:output message="ns:BillOutstandingAmountResponse"/>
</wsdl:operation>

After many hours I found the answer
#RequestWrapper(localName="localRequestName")
Whatever we're giving in the annotation localName will be the SOAP Request method name.

Related

Java SOAP WebService - How to accept single input parameter

I'm developing a SOAP based Webservice API which would be used by a third party system. WSDL file and endpoint URL would be shared with them and they invoke my Web service by passing an input parameter and get the response back
So far, I have created the Web Service API including WSDL, Services Classes, Helper Classes, DAO, Ibatis) and tested using SOAP UI by passing the input parameter, the request hits the databse and returning the response fine. Attached the WSDL file and SOAP request and response.
I got two questions,
The 3rd Party system is asking for an API documentation and SOAP Envelope. What should I give?
The 3rd party system has to invoke my service by passing the input parameter sQuoteRef. How would they usually do it? I'm not concerned about the client code here but how would the request from 3rd party look like and what changes I should make in my WSDL or Java classes to receive the input parameter and pass on to my service class?
Any inputs would be helpful in completing my task. Many Thanks!
WSDL File
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="EmpService" targetNamespace="http://emp.provider.integration.gi.sample.ie/EmpService/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://Emp.provider.integration.gi.sample.ie/EmpService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://Emp.provider.integration.gi.sample.ie/EmpService/">
<xsd:element name="EmpRequestVO">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="sQuoteRef" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EmpResponseVO">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="sQuoteStatus" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetEmpTransactionSoapIn">
<wsdl:part element="tns:EmpRequestVO" name="parameters"/>
</wsdl:message>
<wsdl:message name="GetEmpTransactionSoapOut">
<wsdl:part element="tns:EmpResponseVO" name="parameters"/>
</wsdl:message>
<wsdl:portType name="EmpServiceSoap">
<wsdl:operation name="getEmpTransaction">
<wsdl:input message="tns:GetEmpTransactionSoapIn"/>
<wsdl:output message="tns:GetEmpTransactionSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EmpServiceSoap" type="tns:EmpServiceSoap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getEmpTransaction">
<soap:operation soapAction="getEmpTransaction" 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="PLUSEmpServices">
<wsdl:port binding="tns:EmpServiceSoap" name="EmpServiceSOAP">
<soap:address location="http://localhost:9080/WebServices/services/EmpServiceSOAP"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
End Point URL
http://localhost:9080/PLUSEmpServices/services/EmpServiceSOAP
SOAP REQUEST in SOAP UI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtw="http://emp.provider.integration.gi.sample.ie/EmpService/">
<soapenv:Header/>
<soapenv:Body>
<rtw:EmpRequestVO>
<sQuoteRef>12123118</sQuoteRef>
</rtw:EmpRequestVO>
</soapenv:Body>
</soapenv:Envelope>
SOAP RESPONSE in SOAP UI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p900:EmpResponseVO xmlns:p900="http://emp.provider.integration.gi.sample.ie/EmpService/">
<sQuoteStatus>Active</sQuoteStatus>
</p900:EmpResponseVO>
</soapenv:Body>
</soapenv:Envelope>
The 3rd Party system is asking for an API documentation and SOAP Envelope. What should I give?
To start APIs integration with external parties, your clients require a technical API document that will be a reference to complete APIs integration and a base for any technical communication between the teams. The technical document may includes the following details:
Brief description for different available web-services APIs and their requirements.
APIs communications flow. This will be useful in case the clients need to call more than one services in specific sequence. Including flow diagram will be possible option to explain the system flow.
Test environment details like WSDL URL and access credentials like username, password, agent code, etc.
Detailed description for all fields needed to send a valid request to the server. Fields details may include the following:
a. Filed name.
b. Description.
c. Data Type.
d. Max length.
e. Mandatory, Optional or Conditional.
f. Possible values if any.
All possible response codes a long with their description sent by server API to client API which indicates the successful or failure of transaction process(s). For example (0000 means Success, E001 means validation error, E002 system error, 9999 unknown error, etc.).
Note: Response codes should cover various rejection cases.
Security Section that explain how the data is exchange securely between client and server application.
a. Mention additional Encryption mechanism for part or all request data if any.
b. Communication type with the client wither it is over VPN or accessed public
over https URL. Note the URL you mentioned in your question is deployed in your local machine and it will not be available publicly.
Sample SOAP request(s) and response(s) xml format for all available API’s web methods.
Mention any additional rules or constrains on APIs connectivity.
The 3rd party system has to invoke my service by passing the input parameter sQuoteRef. How would they usually do it? I'm not concerned about the client code here but how would the request from 3rd party look like and what changes I should make in my WSDL or Java classes to receive the input parameter and pass on to my service class?
If I understand you correctly your are asking how should I change WSDL or Java classes to accept client request correctly ? Usually the server side API has the upper hand in XML format need to be exchanged and in your case it should be mentioned in WSDL. So the client will create a valid request as per definition mentioned in server WSDL URL.
Further reading that my be useful on how to generate WSDL from Java classes:
Eclipse WSDL generator (from java class)?
SOAP fault handling in java

SOAP service response cannot be mapped

This problem has had me stumped for almost two days now, I really need some help figuring it out.
I have used wsimport to generate code from two different .wsdl files for a Java project.
The first service works just fine but for some reason the response from the second service cannot be unmarshalled to a response object.
Working service:
#WebMethod(action = "[actionName]")
#WebResult(name = "getSimpleCompanyInfoResponse", partName = "getSimpleCompanyInfoResponse")
public GetSimpleCompanyInfoResponse getSimpleCompanyInfo(
#WebParam(name = "getSimpleCompanyInfoRequest", partName = "getSimpleCompanyInfoRequest") GetSimpleCompanyInfoRequest getSimpleCompanyInfoRequest);
Response POJO:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "getSimpleCompanyInfoResponse", propOrder = {
//variables
})
public class GetSimpleCompanyInfoResponse {
//variables
}
Response XML:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:getSimpleCompanyInfoResponse>
<getSimpleCompanyInfoResponse>
//variables
</getSimpleCompanyInfoResponse>
</ns1:getSimpleCompanyInfoResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
NOT working service:
#WebMethod(operationName = "PersonnelInfo", action = "[actionName]")
#WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse")
public PersonnelInfoResponse personnelInfo(
#WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest);
Response POJO:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "PersonnelInfoResponse", propOrder = {
//variables
})
public class PersonnelInfoResponse {
//variables
}
Response XML:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:PersonnelInfoResponse>
//variables
</ns1:PersonnelInfoResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Using -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true or monitoring with Wireshark I can see the Response envelope from the second service coming through just fine and unmarshalling doesn't throw any exceptions but in the end PersonnelInfoResponse is null.
The only difference I can see is that the second service response payload in the XML is missing the outer element which seems to be the problem. However, I do not know how to "fix" it so it doesn't look for the outer element.
If anything was unclear or missing please let me know and I'll try to give you all the information.
EDIT:
No, I unfortunately don't have any control over the service itself, I only have the .wsdl and .xsd.
I'm calling the service like this:
ReportsControllerPortType port = new ReportsControllerService().getReportsControllerPort();
PersonnelInfoRequest request = new PersonnelInfoRequest();
//fill the required fields in the request, username, password, etc.
PersonnelInfoResponse response = port.personnelInfo(request);
The client-side service stubs (ReportsControllerService & ReportsControllerPortType) are also automatically generated by wsimport according to the .wsdl and .xsd.
EDIT 2:
Removing the operation name doesn't work, the service fails to initialize. Following are the definitions from both .wsdl-s:
Working service:
<wsdl:message name="getSimpleCompanyInfoRequest">
<wsdl:part name="getSimpleCompanyInfoRequest" type="tns:getSimpleCompanyInfoRequest" />
</wsdl:message>
<wsdl:message name="getSimpleCompanyInfoResponse">
<wsdl:part name="getSimpleCompanyInfoResponse" type="tns:getSimpleCompanyInfoResponse" />
</wsdl:message>
<wsdl:portType name="MonitoringControllerPortType">
<wsdl:operation name="getSimpleCompanyInfo">
<wsdl:input message="tns:getSimpleCompanyInfoRequest" />
<wsdl:output message="tns:getSimpleCompanyInfoResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MonitoringControllerBinding" type="tns:MonitoringControllerPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getSimpleCompanyInfo">
<soap:operation soapAction="[domain]/#getSimpleCompanyInfo" style="rpc" />
<wsdl:input>
<soap:body use="literal" namespace="[namespaceUri]" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="[namespaceUri]" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MonitoringControllerService">
<wsdl:port name="MonitoringControllerPort" binding="tns:MonitoringControllerBinding">
<soap:address location="[serviceUri]" />
</wsdl:port>
</wsdl:service>
Not working service:
<wsdl:message name="PersonnelInfoRequest">
<wsdl:part name="PersonnelInfoRequest" type="tns:PersonnelInfoRequest" />
</wsdl:message>
<wsdl:message name="PersonnelInfoResponse">
<wsdl:part name="PersonnelInfoResponse" type="tns:PersonnelInfoResponse" />
</wsdl:message>
<wsdl:portType name="ReportsControllerPortType">
<wsdl:operation name="PersonnelInfo">
<wsdl:input message="tns:PersonnelInfoRequest" />
<wsdl:output message="tns:PersonnelInfoResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ReportsControllerBinding" type="tns:ReportsControllerPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="PersonnelInfo">
<soap:operation soapAction="[domain]/#PersonnelInfo" style="rpc" />
<wsdl:input>
<soap:body use="literal" namespace="[namespaceUri]" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="[namespaceUri]" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ReportsControllerService">
<wsdl:port name="ReportsControllerPort" binding="tns:ReportsControllerBinding">
<soap:address location="[serviceUri]" />
</wsdl:port>
</wsdl:service>
EDIT 3:
ReportsControllerService and MonitoringControllerService extend javax.xml.ws.Service and contain the definitions of the .wsdl schema location and namespace used. The service class returns a PortType object as you can see:
/**
* This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2
*/
#WebServiceClient(name = "ReportsControllerService", targetNamespace = "[namespaceUri]", wsdlLocation = "[wsdlUri]")
public class ReportsControllerService extends Service {
#WebEndpoint(name = "ReportsControllerPort")
public ReportsControllerPortType getReportsControllerPort() {
return super.getPort(new QName("[namespaceUri]", "ReportsControllerPort"), ReportsControllerPortType.class);
}
}
ReportsControllerPortType is an interface which contains methods for every operation endpoint that exists in the service
/**
* This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2
*/
#WebService(name = "ReportsControllerPortType", targetNamespace = "[namespaceUri]")
#SOAPBinding(style = SOAPBinding.Style.RPC)
#XmlSeeAlso({ObjectFactory.class})
public interface ReportsControllerPortType {
#WebMethod(operationName = "PersonnelInfo", action = "[actionName]")
#WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse")
public PersonnelInfoResponse personnelInfo(
#WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest);
}
}
The thing is, all of those classes are automatically generated by JAX-WS (as you can see from the comments) based on the .wsdl schema. The implementation is abstracted somewhere inside the JDK and I don't have control over that either. Yes, I can refactor the code so I bypass JAX-WS but as I understand it, this is supposed to be like a de facto standard way to consume .wsdl-based SOAP services.
The project uses Spring as a base-framework and I have already confirmed both services will work when I use Spring-WS instead so I can refactor but I want to understand why this way isn't working.
I believe I may have found out why your webservice is misbehaving. According to the specification, an RPC webservice must fulfill the following criteria in its soap binding (i.e. the #SOAPBinding annotation you have there)
A style of RPC: check
A use of LITERAL: check
A parameterStyle of WRAPPED: From the description you've given, it would appear that WRAPPED is not the case here, seeing as you're receiving a naked PersonnelInfoResponse (and possibly sending a naked PersonnelInfoRequest) without any wrapping indicates that the service itself is broken.
An excerpt from the JAX-WS spec:
Use of RPC style requires the use of WRAPPED parameter style. Deviations from this is an error
There is one obvious difference between your 2 calls :
You should try to remove operationName = "PersonnelInfo" from your second call which is not present in the first working one.

SOAP Server in JAVA <-> SOAP Client in C#

I have a problem with a SOAP Server written in JAVA, the project is running as a windows service and not as a webserver (e.g. GLASSFISH).
So the problem is, everytime I make a request from a C# .NET client, the JAVA SOAP server is not able to parse the request. The called function gets a NULL value as input parameter.
The communictaion with JAVA clients, SoapUI, aso. works perfectly but the .NET (C#) clients are sending maleformed requests I think. Because the project is already existing and installed a lot of times, I can't develope it in C#.
I've read a lot of threads with similar problems, but I couldn't find any solution for my case.
I just wrote some simple test cases to show you the problem in a short way.
JAVA Code:
main.java
//...
Endpoint endpoint = Endpoint.create(new WS());
endpoint.publish("http://0.0.0.0:8081/test");
//...
WS.java
//...
#WebService(serviceName = "WS")
#SOAPBinding(style = SOAPBinding.Style.RPC)
public class WS {
#WebMethod(operationName = "echo")
public String echo(#WebParam(name = "val") String val) {
return val;
}
}
The WSDL:
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://webj/" name="WS">
<types/>
<message name="echo">
<part name="val" type="xsd:string"/>
</message>
<message name="echoResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="WS">
<operation name="echo">
<input wsam:Action="http://webj/WS/echoRequest" message="tns:echo"/>
<output wsam:Action="http://webj/WS/echoResponse" message="tns:echoResponse"/>
</operation>
</portType>
<binding name="WSPortBinding" type="tns:WS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="echo">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://webj/"/>
</input>
<output>
<soap:body use="literal" namespace="http://webj/"/>
</output>
</operation>
</binding>
<service name="WS">
<port name="WSPort" binding="tns:WSPortBinding">
<soap:address location="http://xxx:8081/test"/>
</port>
</service>
C# Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<s:Body>
<echo xmlns="http://webj/">
<val xmlns="http://webj/">TEST</val>
</echo>
</s:Body>
</s:Envelope>
JAVA Request
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:std="http://webj/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<std:echo>
<val>TEST</val>
</std:echo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem seems to be the namespave of the parameter "val":
<echo xmlns="http://webj/">
<val xmlns="http://webj/">TEST</val>
</echo>
I've already tested this case in JAVA by adding a namespace to the parameter "val" manually and got the same problem. In C# I've tried with generated WebReferences and ServiceReferences.
(e.g. ServiceReference)
TestService.WSClient proxy = new TestService.WSClient();
String results = proxy.echo("TEST");
Can someone tell me how I can get the JAVA server compatible for .NET requests please?
Thanks for help!
Are you using Java JDK 1.8?
Because I don't think C# .NET is sending the namespace for the parameter, but it's sending an empty namespace like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<s:Body>
<echo xmlns="http://webj/">
<val xmlns="">TEST</val>
</echo>
</s:Body>
</s:Envelope>
Java JDK 1.8 contains a JAX-WS version with a bug. The empty namespaces of the requests of your C# client will be parsed completely wrong, just like your C# example above.
Try using the newsest version of >JAX-WS<.
>Here< you can find the description how to implement the libs.
As I see You have problem in namespaces, So when java parses it, finds no value and that's why you get null in Object values. Try to get the same XML structures from C#

SoapUI MockServices returning html rather than xml response

Using the following sample WSDL file, I've generated a new project in SOAP UI (version 3.5), and created the example test suite, test case, and mock service.
WSDL
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</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>
</definitions>
I can start up the mock service and access via the browser, whereby I see a link to the wsdl and can view it.
However, by using the default generated soap request (as follows), it returns an html response (appears to be the web page) rather than the soap response I have configured.
REQUEST
POST http://localhost:8088/SayHello/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "sayHello"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8088
Content-Length: 467
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:helloservice">
<soapenv:Header/>
<soapenv:Body>
<urn:sayHello soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<firstName xsi:type="xsd:string">James</firstName>
</urn:sayHello>
</soapenv:Body>
</soapenv:Envelope>
RESPONSE
HTTP/1.1 200 OK
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Server: Jetty(6.1.x)
<html><body><p>There are currently 1 running soapUI MockServices</p><ul><li>Hello_Binding MockService</li></ul></p></body></html>
I've configured a sample response as follows :
SAMPLE RESPONSE ON MOCK
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:helloservice">
<soapenv:Header/>
<soapenv:Body>
<urn:sayHelloResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<greeting xsi:type="xsd:string">?</greeting>
</urn:sayHelloResponse>
</soapenv:Body>
</soapenv:Envelope>
Its configured as the default response, so I have no idea why it is not being returned.
Any suggestions? +1's to anything that helps me progress this.
Thanks
No service is started for the endpoint URL from your request: http://localhost:8088/SayHello/. The only started service is located at URL http://localhost:8088/mockHello_Binding as reported in the service response. SoapUI returns list of all started mock services in HTML page when a non-existed one is requested. Consider fixing endpoint address to resolve this issue.
I have hit the same problem using soap ui 5.4.0. It have happend beacuse the path of created mock service was incorrect.
If you click in the soap UI, on the created mock service - properties button on the bottom - you will see that your path looks like /mockBindingservice, it should say /.
To change it, double click on the created mock service, click stop service than settings button (located next to stop and start buttons).Change Path to / and double check host.
Save, start service. Should work now.
I know it is an old post, but hopefully it will help sombody looking for the anwser.
The Url you are hitting is incorrect. The MockService URL is created while you import the WSDL to SOAP with default port 8088.
Solution:
1)Create new Project
2)Import WSDL
3)Check Create Mockervice
4)Then you will SEE the URL where mockservice will run::-->mockSearchURL(for eg)
5)hit HTTP://{IP}:8088/mockSearchURL
DONE!!
i think is the name in Url and the name in request
Url : SayHello
Request : sayHello S and s
name should be matched
I has similar issue with BizTalk 2010 Send Port and Mock SOAPUI webservice.
I found out that the 2 URL er different
When I open this in IE..I see the HTML response.
http://localhost:8088/MockUpdateBasicHttp
When you opened this in IE I got a blank white screen which normally means success.
http://localhost:8088//MockUpdateBasicHttp
The correct URL is with a single '/' after port number.
http://localhost:8088/MockUpdateBasicHttp

Java web service method receiving null argument from C# client

I'm working on a Java 6 application server which has a web service for receiving a SOAP messages containing an HL7 message. The Java application runs on Glassfish 3.1. The client is a third-party developed C# application (which runs on the Microsoft .net 4.0 framework) and it is sending these SOAP messages to the Java server.
My initial issue was that the client was unable to parse the WSDL generated by the server. I have since resolved that by implementing my own custom WSDL and tuning it accordingly. This allowed the client to parse the WSDL and send SOAP messages to my Java server application.
However, each time a message is received on the server side, the parameter (named "putXML") is receiving a null value.
The Glassfish server log shows the following when a message is received:
Received WS-I BP non-conformant Unquoted SoapAction HTTP header: http://MyProject.MyPackage/putHL7Data
Received Message: null
Here is the custom WSDL that I created and associated with my SOAP web service:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
targetNamespace="http://MyProject.MyPackage/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:tns="http://MyProject.MyPackage/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://MyProject.MyPackage/">
<s:element name="putHL7Data">
<s:complexType>
<s:sequence>
<s:element name="putXML" type="s:string" minOccurs="0" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="putHL7DataResponse">
<s:complexType>
<s:sequence>
<s:element name="return" type="s:string" minOccurs="0" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="putHL7DataSoapIn">
<wsdl:part name="parameters" element="tns:putHL7Data"/>
</wsdl:message>
<wsdl:message name="putHL7DataSoapOut">
<wsdl:part name="parameters" element="tns:putHL7DataResponse"/>
</wsdl:message>
<wsdl:portType name="MyHandlerSoap">
<wsdl:operation name="putHL7Data">
<wsdl:input message="tns:putHL7DataSoapIn"/>
<wsdl:output message="tns:putHL7DataSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyHandlerSoap" type="tns:MyHandlerSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="putHL7Data">
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyHandler">
<wsdl:port name="MyHandlerPort" binding="tns:MyHandlerSoap">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
And here is the Java web service:
#WebService(serviceName = "MyHandler", wsdlLocation = "WEB-INF/wsdl/MyHandler.wsdl")
public class MyHandler {
#WebMethod(operationName = "putHL7Data")
public String putHL7Data(#WebParam(name = "putXML") String xml) {
// Handle message
}
}
Is there anything I am doing wrong?
What can I do to fix the Java web service so that it properly receives a non-null value?
Is this an issue with the client? If so, would I need to create some sort of interceptor?
Update
Today I tried creating a quick C# client which uses my Java SOAP web service. Below is the code:
namespace TestSoap
{
class Program
{
static void Main(string[] args)
{
ServiceReference1.MyHandlerSoapClient ws = new ServiceReference1.MyHandlerSoapClient();
string result = ws.putHL7Data("Test");
Console.WriteLine("Response: " + result);
Console.ReadLine();
}
}
}
When I run this client, I receive the same null value in the parameter when I was expecting to see the Test string. Also, I'm expecting result to contain a response string but it too is returning a null value.
Remember, I cannot modify the third-party C# client application. Is there anything I can do on the Java end?
Update 2
I recently added a handler chain class which is capturing and logging the raw SOAP messages. The message being sent by the client looks like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
<putHL7Data xmlns="http://MyProject.MyPackage/">
<putXML>... Encoded XML Here ...</putXML>
</putHL7Data>
</soap:Body>
</soap:Envelope>
After getting pointed in the right direction by #dlawrence, I was able to solve my issue. As I mentioned in the question, I still needed to use a custom built wsdl. I only needed to make a few changes to the wsdl and the Java code to solve the issue.
Here's a diff representing my changes to the wsdl:
--- /tmp/a 2011-09-19 15:05:21.132065003 -0400
+++ /tmp/b 2011-09-19 14:41:28.302064999 -0400
## -15,11 +15,11 ##
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://MyProject.MyPackage/">
+ <s:schema targetNamespace="http://MyProject.MyPackage/">
<s:element name="putHL7Data">
<s:complexType>
<s:sequence>
- <s:element name="putXML" type="s:string" minOccurs="0" maxOccurs="1"/>
+ <s:element name="putXML" type="s:string" form="qualified" minOccurs="0" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
## -47,6 +47,6 ##
<wsdl:binding name="MyHandlerSoap" type="tns:MyHandlerSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="putHL7Data">
- <soap:operation soapAction="" style="document"/>
+ <soap:operation soapAction="http://MyProject.MyPackage/putHL7Data" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
Basically this was a three part fix...
1). I needed to remove the elementFormDefault="qualified" attribute from the <s:schema> tag.
2). Then I had to add the attribute form="qualified" on my <s:element name="putXML" ...> tag.
3). Finally, I needed to make sure I had the attribute soapAction="http://MyProject.MyPackage/putHL7Data" on my <soap:operation> tag.
Here's a diff representing my changes to the Java web method:
--- /tmp/a 2011-09-19 14:57:49.582065002 -0400
+++ /tmp/b 2011-09-19 15:00:06.942065007 -0400
## -1,7 +1,7 ##
#WebService(serviceName = "MyHandler", wsdlLocation = "WEB-INF/wsdl/MyHandler.wsdl")
public class MyHandler {
#WebMethod(operationName = "putHL7Data")
- public String putHL7Data(#WebParam(name = "putXML") String xml) {
+ public String putHL7Data(#WebParam(name = "putXML", targetNamespace="http://MyProject.MyPackage/") String xml) {
// Handle message
}
}
As you can see, all I had to do was add the targetNamespace attribute to my #WebParam.
Have you tried removing the #WebParam attribute? It shouldn't be required as there is no ambiguity with your web service here and it's possible you need to set the targetNamespace in order for it to correctly find the attribute.
i have the same Message in my glassfish console. In my android project with ksoap function i changed the following code:
soapEnvelope.setOutputSoapObject(soapReq);
HttpTransportSE httpTransport = new HttpTransportSE(url,timeOut);
try{
if (headers!=null){
// original code // my headers are null
httpTransport.call("http://service.iswitch.com/", soapEnvelope,headers);
}else{
httpTransport.call("\"http://service.iswitch.com/"\", soapEnvelope);
}
SoapObject result=(SoapObject)soapEnvelope.bodyIn;
if (result.hasProperty("moveResult"))
{
....
it works ... );
the class i generated with http://www.wsdl2code.com

Categories