Web Service ASMX parameter show twice and i only need one - web-services

I have this code is web service asmx
Public Structure AA
Public Num As String
End Structure
Public Structure Resp
Public Ret As String
Public Men As String
End Structure
<WebMethod> _
Public Function RecTab(ByVal dd As List(Of AA)) As Resp
Dim strucResp As New Resp
'Do something
strucResp.Ret = "0"
strucResp.Men = "Message"
Return strucResp
End Function
When i publish, SOAP 1.1 show AA twice and just need one
<soap:Body>
<RecTab xmlns="http://tempuri.org">
<dd>
<AA>
<Num>string</Num>
</AA>
<AA>
<Num>string</Num>
</AA>
</dd>
</RecTab>
</soap:Body>
I try with Public Function RecTab(ByVal dd As AA) As Resp but on SOAP 1.1 doesn't show AA, i get this
<soap:Body>
<RecTab xmlns="http://tempuri.org">
<dd>
<Num>string</Num>
</dd>
</RecTab>
</soap:Body>
I need three levels dd, AA and Num, but just once. How i do to get this?
<soap:Body>
<RecTab xmlns="http://tempuri.org">
<dd>
<AA>
<Num>string</Num>
</AA>
</dd>
</RecTab>
</soap:Body>

Related

Importing the wsdl file in postman

I am trying to access the client URL web service in postman. I used the import link to import the wsdl file client URL in postman and successfully generated the collection. However, upon testing the request, I am unable to retrieve the data from the client server. I am only getting an empty element in the response body. I followed some of the SOAP Web Service tutorial on youtube and it is still the same. The client provided me the valid username for me to test but still the same.
This is my request body:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<zhi_sa_mgt xmlns="urn:mss:jfnllns:df">
<P_DATE>2022-10-22</P_DATE>
<P_NAME>
<item>HPOITY</item>
</P_NAME>
</zhi_sa_mgt>
</soap:Body>
</soap:Envelope>
And the response body:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<zhi_sa_mgt xmlns="urn:mss:jfnllns:df">
<P_DATA/>
</zhi_sa_mgt>
</soap:Body>
</soap:Envelope>
I just wanted to ask, what could be the possible reason/s on why I am getting the empty tag <P_DATA>? This is my first SOAP web service task and I cannot figure out why I cant retrieve the data from the client server. Thank you in advance for your response.

Copy attributes from element in xsl

I have a soap request in context variable, that is a response too:
<soap:Envelope>
<xsl:copy-of select="dp:variable('var://context/Requestdata/STRequest')"/>
</soap:Envelope>
Now, I want that the response will be one new element, with attributes of a specific element from the context variable:
<soap:Envelope>
<NewElement att1="xxx" att2="yyy" att3="zzz"/>
</soap:Envelope>
How can I do this?

WSO2ESB, XPath, split values based on a token in SOAP response

I have a SOAP response message which contains a node value
similar to string A_B_C_D. I need to split each
value based on the underscore (_) and set them in
separate properties.
I checked with Xpath tokenize function but could not find a
way to get the values like array[1], array[2].. separately.
I also did some reading on XSLT mediator but not sure whether
it will help me to achieve this.
Please guide me on how to achieve this objective
Thanks
You can get value like "array[1]" but can't apply tokenize directly on soap:Body with ESB 4.8.1 :
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="MY_VALUE" expression="//soapenv:Body/myNode"/>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Element1" expression="fn:tokenize(syn:get-property('MY_VALUE'),'_')[1]"/>
With this message :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<myNode>A_B_C</myNode>
</soapenv:Body>
</soapenv:Envelope>
property 'Element1' contain : 'A'

How do I remove operation element from soap envelope body in WCF?

I have a WCF service setup mostly to a customer's spec, yet there is one extra element required of an envelope body that I'm trying to exclude based on the customer's sample request.
These are my service and operation contracts:
[ServiceContract(Namespace="http://www.somenamespace.com")]
public interface IProcessPayment
{
[OperationContract]
ResponseSubmitPayment execute(RequestSubmitPayment RequestSubmitPayment);
}
This is what they are sending to test my service with:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
<soapenv:Header/>
<soapenv:Body>
<pay:RequestSubmitPayment>
<!-- irrelevant stuff -->
</pay:RequestSubmitPayment>
</soapenv:Body>
</soapenv:Envelope>
and this is what my service expects (based on SOAPUI):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
<soapenv:Header/>
<soapenv:Body>
<pay:execute> <!-- I want to remove this! -->
<pay:RequestSubmitPayment>
<!-- irrelevant stuff -->
</pay:RequestSubmitPayment>
</pay:execute> <!-- I want to remove this! -->
</soapenv:Body>
</soapenv:Envelope>
How can I configure my WCF service to not require or exclude that element? The client has told me they have many other customers with it successfully tested and implemented. SOAP 1.1 is my understanding of what they're sending.
Thanks in advance!
Not sure it is doable in operationcontract. Try using a message contract, it will give you the flexibility you need. If that fails use an xmlserializer contract with method flag ParameterStyle = SoapParameterStyle.Bare.

How do I use rest-client for ruby to post an image?

I am trying to find a way to use the Postful API and I need to post an image in the body of the request. I am trying to use rest-client (but am open to other ways):
The error I get when I post is HTTP status code 422
Basically, I'm clueless and need guidance. :\
class PostfulsController < ApplicationController
require 'rest_client'
def submit
body = "<?xml version='1.0' encoding='UTF-8'?>
<mail>
<documents>
<document>
<template>
<source>gallery</source>
<name>Postcard: Image fit front</name>
</template>
<sections>
<section>
<name>Text</name>
<text>Hello, World!</text>
</section>
<section>
<name>Image</name>
<attachment>#{attachment_id}</attachment>
</section>
</sections>
</document>
</documents>
<addressees>
<addressee>
<name>John Doe</name>
<address>123 Main St</address>
<city>Anytown</city>
<state>AZ</state>
<postal-code>10000</postal-code>
</addressee>
</addressees>
</mail>"
result = RestClient.post 'http://www.postful.com/service/mail',
body, :content_type => 'text/plain'
end
end
Try
# result will contain the response
result = RestClient.post('http://www.postful.com/service/mail',
request.body,
{:content_type => 'text/plain',
'Authorization: Basic' => 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='}
p result.body
p result.code
p result.headers