I am using SoapUI 5.1.3 version. I am sending below request to the we service.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:upl="http://upload.application.carbon.wso2.org" xmlns:xsd="http://upload.application.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<upl:uploadApp>
<!--Zero or more repetitions:-->
<upl:fileItems>
<!--Optional:-->
<xsd:dataHandler>UEsDBBLjAuMC52MjAxMTA1MjcxNTIxMDAvYXJ0aWZhY3QueG1sUEsFBgAAAAAJAAkAMAMAAC4IAAAAAA==</xsd:dataHandler>
<!--Optional:-->
<xsd:fileName>ESBproject1-1.0.0.car</xsd:fileName>
<!--Optional:-->
<xsd:fileType>jar</xsd:fileType>
</upl:fileItems>
</upl:uploadApp>
</soapenv:Body>
</soapenv:Envelope>
at the web service end, when I check the dataHandler value seems like it is truncated at the end of the string. I inserted file using Insert file as Base64 context menu option. I changed Enable MTOM property to true. what could be the reason for missing a part of data that sends to web service?
UPDATE
I wrote a HTTP server to capture the soap request without sending it to the web service by changing the url in SoapUI to http://localhost:5000/. below is the server I wrote
public static void main(String[] args) throws Exception {
ServerSocket server = new ServerSocket(5000);
Socket conn = server.accept();
StringBuilder sb = new StringBuilder();
//getBytes() method returns a byte array for InputStream
ByteArrayInputStream reader = new ByteArrayInputStream(getBytes(conn.getInputStream()));
int ch;
while ( (ch = reader.read()) != -1) {
sb.append((char)ch);
}
System.out.println("Your message: "+sb.toString());
}
after running the HTTP server I sent the above mentioned soap request and I could have seen that http client also received the same request as above. but since I have enabled MTOM, SoapUI request should be modified and HTTP server should received different request from the above soap request. According to MTOM definition as described in this SO question, binary dataHandler value should be moved to out of the envelop. it should be replaced with xop tag and a reference. As an example envelop should be something like below.
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns2:uploadApp xmlns:ns2="http://upload.application.carbon.wso2.org">
<ns2:fileItems>
<ns1:dataHandler xmlns:ns1="http://upload.application.carbon.wso2.org/xsd">
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.4aefed8d8cef221bc29fec3e7341b21813a53a5181b39c2b#apache.org" />
</ns1:dataHandler>
<ns1:fileName xmlns:ns1="http://upload.application.carbon.wso2.org/xsd">ESBproject1-1.0.0.car</ns1:fileName>
<ns1:fileType xmlns:ns1="http://upload.application.carbon.wso2.org/xsd">jar</ns1:fileType>
</ns2:fileItems>
</ns2:uploadApp>
</soapenv:Body>
</soapenv:Envelope>
my problem now is, is that the correct way to enable MTOM in SoapUI or is this a bug?
For future readers:
I inserted file using Insert file as Base64 context menu option. I changed Enable MTOM property to true.
Inserting the file as Base64 makes the content being included in the XML directly, not as attachment. You'd see something like:
<myfile>some long Base64-encoded string here</myfile>
For this, SoapUI will not convert the Base64 string into an attachment, and hence no MTOM is needed. You could select both Enable MTOM and Force MTOM, but even that will not send the binary content as attachment. Instead, you'd then get a multipart message with just a single part (being the XML with the embedded Base64 encoded file).
To get an MTOM attachment, you should add the file to the request as attachment (see the "Attachment" tab underneath the request editor), which will get you a content id. Next, refer to that content id using cid:, like:
<myfile>cid:myfile.png</myfile>
Now, regardless of Force MTOM, SoapUI will create a multipart message with two parts.
Document at http://www.soapui.org/soap-and-wsdl/headers-and-attachments.html says that "enable MTOM = true" does following things.
1-The outgoing message is being sent as a Mime Multipart message with the corresponding MTOM Content-Type
2-The first Mime Part contains the message, the second contains the attachment
3-The ClaimImage element in the message contains an XOP Include element referring to the second Mime-Part (highlighted)
Related
Currently having an error Invalid UTF-8 start byte 0x8b (at char #2, byte #-1).
The response is currently zipped and would like to know how to transform the received message into xml format. The response for the service at soapUI has a Content-Type: binary/x-gzip.
What can be the messageFormater and messageBuilder in WSO2 in order to parse the data received? Or, what type of property should be used?
You have to use BinaryRelayBuilder and ExpandingMessageFormatter to just pass data through the ESB without built or formatted. This message builder and message formatter need to added into the axis2.xml file located in <EI_HOME>/conf/axis2 directory.
I am exposing a SOAP service using Tomcat, Apache CXF and Spring Boot. The web service has MTOM enabled and it works as expected when testing it from SOAP UI.
The problem is that when I try to get the message with MTOM disabled from SOAP UI, I still get the message with an XOP attachment. The options from SOAP UI that I use are: Enable MTOM: false; Force MTOM: false.
I have tried to set the Accept header on the request to application/xml instead of application/xop+xml, but I still get the same thing.
The only time when I get the Byte64 stream is when I test with a file which is smaller than the threshold that I've set:
#MTOM(enabled = true, threshold = 2048)
What I would need is MTOM to be optional when it is set to enabled and to depend on the request, not only on the threshold, could this be a problem with SOAP UI or does my current configuration ignore the request parameters?
I need this because some clients of the web service don't support MTOM.
Here is the object I return from the exposed method:
public class Document {
private DataHandler fileData;
public DataHandler getFileData() {
return fileData;
}
public void setFileData(DataHandler fileData) {
this.fileData = fileData;
}
}
You can't control from the client whether you want the server to respond with an xop attachment or without.
JAX-WS, and I think none of its implementations such as CXF for example, care about the Accept header since it's not specified in the SOAP specifications that the server has to read if from the request, nor which value it should write on the response. So it makes no difference if you put application/xml or text/xml or any other.
If the server has MTOM enabled it must always (as long as it falls into the threshold range) send back a soap response using MTOM.
The options from SOAP UI that I use are: Enable MTOM: false; Force MTOM: false
These are options for the request message, so in case you are sending a file in your request it would be encoded as a base64 attachment, meaning you are just disabling MTOM for the request.
It's a bummer but basically you are just left with two options:
Modify the server and disable MTOM or try to do something with interceptors like reading a value from the request and enabling/disabling mtom programatically for that single message based on that value. It's like implementing yourself a mechanism to decide wether that client supports MTOM or not.
Modify the clients that don's support MTOM which probably you can't do if you are asking this question.
Im trying to do simple web service test using JMeter. I'm using SOAP/XML-RPC Request with simpliest configuration
URL = https://...address here..?wsdl
SOAP action and Use KeepAlive stay unchecked
XML request is loaded from file, correctly
What is more i have added View Result Tree to see results.
Thats all.
Problem is i'm still getting whole wsdl file as a response (i have expected a normal soap response for my xml soap requst).
I have tested in SOAPui this request and url - everythink working fine. Do i need do add smth more? maybe this is problem with https protocol?
What is more i have tried WebService (SOAP) Request (DEPRECATED) however im getting exception becouse of using https while i want to use load WSDL.
Any ideas to solve my problem?
Here is a request from View Result Tree
POST https://...address here..?wsdl
POST data:
Filename: D:\install\apache-jmeter-2.11\TEST\request.xml
<actual file content, not shown here>
[no cookies]
Request Headers:
Content-Type: text/xml
Connection: close
User-Agent: Jakarta Commons-HttpClient/3.1
Host: hostname
Content-Length: 1826
EDIT: i solved this problem by doing configuration like this:
ULR = https://..address here.. (NO WSDL)
SOAP action specified (url from wsdl)
KeepAlive checked
XML pasted in textbox section
However when i load xml from file - test fails with message couldnt parse stream. The same message pasted into textbox section - works perfectly. Whats wrong?
Configuration:
URL : scheme://..address here.. (NO WSDL)
SOAP action specified (url from wsdl)
KeepAlive checked
path to XML file pasted into right section
File encoding:
XML was not loading as i expected because of encoding.
I had set UTF-8 with BOM encoding while my service expected UTF-8 without BOM.
Please consider the following code from Ben Nadel's post:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Subscriber.AddAndResubscribe
xmlns="http://api.createsend.com/api/">
<ApiKey>#campaignMonitorKey#</ApiKey>
<ListID>#campaignMonitorList#</ListID>
<Email>kim#sweet-n-sassy.com</Email>
<Name></Name>
</Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>
I understood that AddAndResubscribe is the operation name and Subscriber.AddandResubscribe is the input name. I am wondering what does campaignMonitorKey, campaignMonitorList , the value in the Email tag and an empty Name tag means? Could anyone please explain?
Source for WSDL: http://api.createsend.com/api/api.asmx?WSDL
Source for the POST: http://www.bennadel.com/blog/1809-Making-SOAP-Web-Service-Requests-With-ColdFusion-And-CFHTTP.htm
Thanks
In Ben Nadel's post, he's sending data to Campaign Monitor's newsletter subscription API. The structure of the soap body is dictated in this case by Campaign Monitor. What is being passed are the values needed to use their addAResubscribe method.
Since I don't use Campaign Monitor, I'm only making an educated guess here:
ApiKey: I'm assuming is an authentication key you gain when you sign up. This allows Campaign Monitor know who is sending the request, and that the customer is still active. Notice that #campaignMonitorKey#. This value would be set else were in the application. Since it's Ben's ApiKey, the setting of this value was left out of his example.
ListID: would be the ID representing a mailing lists. Once again, this would be set else were in the application, and wasn't shared in the example.
Email: the email being added.
Name would be the name of the person reviving the email.
When consuming soap request myself, I first use an application called SoapUI. This tool can generate sample request bodys for all the methods exposed by the WSDL URL. From here you can try putting in your own values and get a response back.
I have a webservice client code which accesses a service (Axis2 based). I tried changing the content type in the request header using the following code.
ServiceClient serviceClient = stub._getServiceClient();
Options options = serviceClient.getOptions();
options.setProperty(HTTPConstants.CHUNKED, "true");
options.setProperty(Constants.Configuration.ENABLE_HTTP_CONTENT_NEGOTIATION,"true");
options.setProperty(Constants.Configuration.MESSAGE_TYPE,"text/xml");
But the above code was not working for the content type text/xml .But It worked when I used the content type application/xml .I was not able to set the content type as text/xml.
Can anybody give me a solution for this?
Your client may be using the wrong SOAP version to format its request. text/xml is the SOAP 1.1 content type. application/soap+xml is the content type for SOAP 1.2.
This page illustrates how to change the SOAP version.
serviceClient.getOptions().setSoapVersionURI(
org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
will set the SOAP version to 1.1, for example.