In my wsdl:message i got two parameters, firstname and lastname:
<message name="setName">
<part name="firstname" type="xsd:string"></part>
<part name="lastname" type="xsd:string"></part>
</message>
I want to define the "firstname" part as required, and the "lastname" part as optional.
How do i do that?
In WSDL parts can not be optional. They are always required. If you need optional parts, you will have to create one part that refers to a XSD complexType that then can have optional elements.
You can add nullable to lastname, so firstname is required:
<message name="setName">
<part name="firstname" type="xsd:string"></part>
<part name="lastname" xsi:nil="true" type="xsd:string"></part>
</message>
If you do so, your soap body look like this (empty or filled lastname):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://www.example.com/MyService/">
<soapenv:Header/>
<soapenv:Body>
<user:setName>
<firstname>John</firstname>
<lastname></lastname>
</user:setName>
</soapenv:Body>
</soapenv:Envelope>
Or even without lastname:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://www.example.com/MyService/">
<soapenv:Header/>
<soapenv:Body>
<user:setName>
<firstname>John</firstname>
</user:setName>
</soapenv:Body>
</soapenv:Envelope>
Related
I am getting this error and not receiving output. Can you please help me out?
<Messages>
<Status>-999</Status>
<Errors>
<Error xsi:type="xsd:string">Unexpected Error has occured </Error>
</Errors>
<Warnings/>
</Messages>
Here is the complete code:
Sent
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://www.echo.com/">
<soapenv:Header/>
<soapenv:Body>
<echo:GetQuote>
<!--Optional:-->
<echo:echoRateRequest>
<!--Optional:-->
<echo:AuthInfo>
<!--Optional:-->
<echo:UserId></echo:UserId>
<!--Optional:-->
<echo:Password></echo:Password>
</echo:AuthInfo>
<!--Optional:-->
<echo:Requests>
<!--Zero or more repetitions:-->
<echo:Request>
<echo:TotalWeight>1000</echo:TotalWeight>
<!--Optional:-->
<echo:Items>
<!--Zero or more repetitions:-->
<echo:Item OriginId="1" DestinationId="1">
<echo:Class>70</echo:Class>
<echo:Weight>1000</echo:Weight>
</echo:Item>
</echo:Items>
<!--Optional:-->
<echo:Accessorials>
<!--Zero or more repetitions:-->
<echo:Accessorial>
<echo:AccessorialId>12</echo:AccessorialId>
<echo:Charge>0</echo:Charge>
<!--Optional:-->
<echo:PickDel></echo:PickDel>
<!--Optional:-->
<echo:RateType></echo:RateType>
<!--Optional:-->
<echo:Description>?</echo:Description>
</echo:Accessorial>
</echo:Accessorials>
<!--Optional:-->
<echo:Origin Id="">
<!--Optional:-->
<echo:Name></echo:Name>
<!--Optional:-->
<echo:Address1></echo:Address1>
<!--Optional:-->
<echo:Address2></echo:Address2>
<!--Optional:-->
<echo:City></echo:City>
<!--Optional:-->
<echo:State></echo:State>
<!--Optional:-->
<echo:Zip>91101</echo:Zip>
</echo:Origin>
<!--Optional:-->
<echo:Destination Id="?">
<!--Optional:-->
<echo:Name></echo:Name>
<!--Optional:-->
<echo:Address1></echo:Address1>
<!--Optional:-->
<echo:Address2></echo:Address2>
<!--Optional:-->
<echo:City></echo:City>
<!--Optional:-->
<echo:State></echo:State>
<!--Optional:-->
<echo:Zip>60425</echo:Zip>
</echo:Destination>
<echo:PickupDate>2015-10-03</echo:PickupDate>
<!--Optional:-->
<echo:ShipmentType></echo:ShipmentType>
<echo:PalletQty>0</echo:PalletQty>
<echo:ReturnMultipleCarriers>false</echo:ReturnMultipleCarriers>
<echo:SaveQuote>false</echo:SaveQuote>
</echo:Request>
</echo:Requests>
</echo:echoRateRequest>
</echo:GetQuote>
</soapenv:Body>
</soapenv:Envelope>
Received response:
<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>
<GetQuoteResponse xmlns="http://www.echo.com/">
<GetQuoteResult>
<TotalRateQuotes>1</TotalRateQuotes>
<RateQuote>
<QuoteId>0</QuoteId>
<Request>
<TotalWeight>1000</TotalWeight>
<Items>
<Item OriginId="1" DestinationId="1">
<Class>70</Class>
<Weight>1000</Weight>
</Item>
</Items>
<Accessorials>
<Accessorial>
<AccessorialId>12</AccessorialId>
<Charge>0</Charge>
<PickDel/>
<RateType/>
<Description>?</Description>
</Accessorial>
</Accessorials>
<Origin Id="">
<Name/>
<Address1/>
<Address2/>
<City/>
<State/>
<Zip>91101</Zip>
</Origin>
<Destination Id="?">
<Name/>
<Address1/>
<Address2/>
<City/>
<State/>
<Zip>60425</Zip>
</Destination>
<PickupDate>2015-10-03T00:00:00</PickupDate>
<ShipmentType/>
<PalletQty>0</PalletQty>
<ReturnMultipleCarriers>false</ReturnMultipleCarriers>
<SaveQuote>false</SaveQuote>
</Request>
<RateDetails/>
<Messages>
<Status>-999</Status>
<Errors>
<Error xsi:type="xsd:string">Unexpected Error has occured.</Error>
</Errors>
<Warnings/>
</Messages>
</RateQuote>
</GetQuoteResult>
</GetQuoteResponse>
</soap:Body>
</soap:Envelope>
I was really working hard on it and was unable to find solution on this issue. If you want you can test using these links your self.
Standard (production):
http://services.echo.com/Quote.asmx
http://services.echo.com/Quote.asmx?wsdl
Tried from my end as well
Request:
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetQuote xmlns="http://www.echo.com/">
<echoRateRequest>
<AuthInfo>
<UserId>test-soap</UserId>
<Password>xxxx</Password>
</AuthInfo>
<Requests>
<Request>
<TotalWeight>3.12</TotalWeight>
<PickupDate>2002-09-24-06:00</PickupDate>
<PalletQty>12</PalletQty>
<ReturnMultipleCarriers>true</ReturnMultipleCarriers>
<SaveQuote>true</SaveQuote>
</Request>
<Request>
<TotalWeight>12.4</TotalWeight>
<PickupDate>2002-09-24-06:00</PickupDate>
<PalletQty>34</PalletQty>
<ReturnMultipleCarriers>true</ReturnMultipleCarriers>
<SaveQuote>true</SaveQuote>
</Request>
</Requests>
</echoRateRequest>
</GetQuote>
</soap12:Body>
</soap12:Envelope>
Response I got
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetQuoteResponse xmlns="http://www.echo.com/">
<GetQuoteResult>
<TotalRateQuotes>1</TotalRateQuotes>
<RateQuote>
<QuoteId>0</QuoteId>
<Request>
<TotalWeight>0</TotalWeight>
<Items/>
<Accessorials/>
<Origin/>
<Destination/>
<PickupDate>2002-09-24T01:00:00-05:00</PickupDate>
<PalletQty>12</PalletQty>
<ReturnMultipleCarriers>true</ReturnMultipleCarriers>
<SaveQuote>true</SaveQuote>
</Request>
<RateDetails/>
<Messages>
<Status>-999</Status>
<Errors>
<Error xsi:type="xsd:string">Unexpected Error has occured.</Error>
</Errors>
<Warnings/>
</Messages>
</RateQuote>
</GetQuoteResult>
</GetQuoteResponse>
</soap:Body>
</soap:Envelope>
It means there is a problem in the values we send , please check the logs in the servers what is causing this error .. 2nd look at the documentation what values each field must take . if we dont have proper input we always end with no happy response. the key here is to send proper values.
How can I parse the SOAP response xml using Spring Batch. Creating bean for org.springframework.batch.item.xml.StaxEventItemReader and passring fragmentRootElementName parameter value as XMLData returned nothing, probably unmarshalling issue.
SOAP XML
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<WSCorIDSOAPHeader xmlns="http://www.wilytech.com/" CorID="5A35F9B79906411A00156F9B91FFE1EB,1:1,0,0,wl-flor-apvm106|Tomcat|dorms106-1|WebServices|Client|http_//tempuri.org/|submit,2,AgAAAdRIQgAAAAFGAAAAAQAAABFqYXZhLnV0aWwuSGFzaE1hcAAAAAdIQgAAAAJGAAAAAgAAABBqYXZhLmxhbmcuU3RyaW5nABBBcHBNYXBDYWxsZXJUeXBlSEIAAAADRQAAAAIACldlYlNlcnZpY2VIQgAAAARFAAAAAgARQXBwTWFwQ2FsbGVyQWdlbnRIQgAAAAVFAAAAAgAKZG9ybXMxMDYtMUhCAAAABkUAAAACAA9DYWxsZXJUaW1lc3RhbXBIQgAAAAdFAAAAAgANMTQ1NzUwNzQwMDExOUhCAAAACEUAAAACABZBcHBNYXBDYWxsZXJNZXRob2ROYW1lSEIAAAAJRQAAAAIAGmh0dHBfLy90ZW1wdXJpLm9yZy98c3VibWl0SEIAAAAKRQAAAAIAEEFwcE1hcENhbGxlckhvc3RIQgAAAAtFAAAAAgAPd2wtZmxvci1hcHZtMTA2SEIAAAAMRQAAAAIAE0FwcE1hcENhbGxlclByb2Nlc3NIQgAAAA1FAAAAAgAGVG9tY2F0SEIAAAAORQAAAAIAClR4blRyYWNlSWRIQgAAAA9FAAAAAgAjNUEyRDkxRjE5OTA2NDExQTAwMTU2RjlCRTAyOEIwNUM5ODU=" />
<To soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://fldcvpswa0806.something.com/RTPTransaction/SubmitTransaction.svc?wsdl</To>
<Action soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ISubmitTransaction/Submit</Action>
</soap:Header>
<soap:Body>
<ns2:Submit xmlns="http://schemas.datacontract.org/2004/07/RTPTransaction" xmlns:ns2="http://tempuri.org/" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns2:XMLData>
<Creation>2016-03-09 02:10:00</Creation>
<EndOfDays />
<Transactions>
<Transaction>
<BusinessDate>2016-03-09</BusinessDate>
<Items>
<Item>
<Extended>35.0</Extended>
<Number>480000015523</Number>
<Quantity>1</Quantity>
<Taxes>
<Tax>
<Amount>0.00</Amount>
<Rate>0.000</Rate>
<State>FL</State>
<Type>N</Type>
</Tax>
</Taxes>
<Unit>35.0</Unit>
</Item>
</Items>
<Stamp>2016-03-09 00:00:00</Stamp>
<Store>01006</Store>
</Transaction>
</Transactions>
</ns2:XMLData>
</ns2:Submit>
</soap:Body>
</soap:Envelope>
SOAP UI error from setup groovy script
It is something wrong when I define the first string from the setNodeValue method. The XPath is not correct or I might be missing something.
Any ideas?
Error : org.apache.xmlbeans.XmlException:error:Unexpected element: CDATA
SOAP Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:log="Logisense_EngageIP">
<soapenv:Header>
<log:AuthHeader>
<!--Optional:-->
<log:Username>vv</log:Username>
<!--Optional:-->
<log:Password>vv</log:Password>
</log:AuthHeader>
</soapenv:Header>
<soapenv:Body>
<log:CreateUser>
<!--Optional: DYNAMIC VALUE -->
<log:username>${username}</log:username>
<!--Optional:-->
<log:password>test</log:password>
<!--Optional:-->
<log:alternativeUsername>de</log:alternativeUsername>
<!--Optional:-->
<log:roleName>admin</log:roleName>
<!--Optional:-->
<log:cultureName>English</log:cultureName>
<!--Optional:-->
<log:languageName>English</log:languageName>
<!--Optional: -->
<log:ownerUsername>admin</log:ownerUsername>
<!--Optional:-->
<log:parentUsername></log:parentUsername>
<!--Optional:-->
<log:userStatusTypeName>Enabled</log:userStatusTypeName>
<!--Optional:-->
<log:creditRatingName>Default</log:creditRatingName>
<!--Optional:-->
<log:billGroupName>Default</log:billGroupName>
<log:expireDate>2015-09-12</log:expireDate>
</log:CreateUser>
</soapenv:Body>
</soapenv:Envelope>
Groovy script setup :
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("CreateUserRequest1#Request")
holder.setNodeValue("/soapenv:Envelope/soapenv:Body/log:CreateUser/log:username","Jose Amaral")
holder.updateProperty()
I'm trying to figure out how to write the array part of a SOAP request whose relevant part of its WSDL is this:
<xsd:complexType name="ArrayOfProductInfo">
<xsd:complexContent>
<xsd:restriction base="soap-enc:Array">
<xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:ProductInfo[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ProductInfo">
<xsd:all>
<xsd:element name="productID" type="xsd:string"/>
<xsd:element name="quantity" type="xsd:int"/>
<xsd:element name="price" type="xsd:float"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="clCostRequest">
<xsd:all>
<xsd:element name="language" type="xsd:string"/>
<xsd:element name="items" type="tns:ArrayOfProductInfo"/>
<xsd:element name="shipmentOriginCountry" type="xsd:string"/>
<xsd:element name="shipmentDestinationCountry" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
With soapUI, I'm able to see that the SOAP request should look as follows, except for what I've wrapped in "????" tags, which soapUI is not displaying. (Note also that it's displaying this node as a self-closing tag.)
<soapenv:Envelope mlns:xsi="http:...">
<soapenv:Header/>
<soapenv:Body>
<clCost soapenv:encodingStyle="http://schemas.xmlsoap.org/...">
<request xsi:type="clCostRequest">
<language xsi:type="xsd:string">en</language>
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]"/>
<????>productID</????>
<????>quantity</????>
<????>price</????>
<????>productID</????>
<????>quantity</????>
<????>price</????>
<shipmentOriginCountry xsi:type="xsd:string">US</shipmentOriginCountry>
<shipmentDestinationCountry xsi:type="xsd:string">DE</shipmentDestinationCountry>
</request>
</clCost>
</soapenv:Body>
</soapenv:Envelope>
I need to pass in that "ProductInfo" array but I don't know what its tags should look like. I've tried this to no avail:
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]">
<ProductInfo xsi:type="tns:ProductInfo">
<productID xsi:type="xsd:string">86595</productID>
<quantity xsi:type="xsd:int">50</quantity>
<price xsi:type="xsd:float">1.99</price>
</ProductInfo>
<ProductInfo xsi:type="tns:ProductInfo">
<productID xsi:type="xsd:string">12215</productID>
<quantity xsi:type="xsd:int">60</quantity>
<price xsi:type="xsd:float">5.99</price>
</ProductInfo>
</items>
Any hints or references to similar examples would be greatly appreciated!
SoapUI will translate the WSDL you give him and display you the requests and their parameters. Whatever SOAPUI generated from WSDL should be correct. Therefore I advise you to check your WSDL, because the fault is there.
This should Work
<soapenv:Envelope mlns:xsi="http:...">
<soapenv:Header/>
<soapenv:Body>
<clCost soapenv:encodingStyle="http://schemas.xmlsoap.org/...">
<request xsi:type="clCostRequest">
<language xsi:type="xsd:string">en</language>
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]">
<item xsi:type="xsd:ProductInfo">
<productID xsi:type="xsd:string">86595</productID>
<quantity xsi:type="xsd:int">50</quantity>
<price xsi:type="xsd:float">1.99</price>
</item>
<item xsi:type="xsd:ProductInfo">
<productID xsi:type="xsd:string">12215</productID>
<quantity xsi:type="xsd:int">60</quantity>
<price xsi:type="xsd:float">5.99</price>
</item>
</items>
<shipmentOriginCountry xsi:type="xsd:string">US</shipmentOriginCountry>
<shipmentDestinationCountry xsi:type="xsd:string">DE</shipmentDestinationCountry>
</request>
</clCost>
</soapenv:Body>
</soapenv:Envelope>
I want to make a SOAP call to a local web service. The web service is defined via a WSDL file (see below). I want to use Perl and SOAP::Lite. I tried this:
use strict ;
use warnings ;
use SOAP::Lite ;
my $endpoint = qq{http://example.com:2222/orawsv/PS_API/ACCOUNT_WS} ;
my $tns = 'http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS' ;
my $method_urn = $tns ;
my $soapaction = $tns ;
my $method = 'GET_BY_ACCOUNT_NUMBER' ;
my $sObj = SOAP::Lite->new(uri => $soapaction, proxy => $endpoint) ;
my $response = $sObj->call(SOAP::Data->name($method)->attr({ 'xmlns' => $method_urn})
=> SOAP::Data->name('ACCOUNT_NUMBER-VARCHAR2-IN' => '274724')) ;
print $response->faultstring() . "\n";
However, this results in an XML parsing failed error message. What would be the correct SOAP::Lite code to make this method call?
The HTTP request generated by the above is
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 553
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS#GET_BY_ACCOUNT_NUMBER"
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GET_BY_ACCOUNT_NUMBER xmlns="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS">
<ACCOUNT_NUMBER-VARCHAR2-IN xsi:type="xsd:int">274724</ACCOUNT_NUMBER-VARCHAR2-IN>
</GET_BY_ACCOUNT_NUMBER>
</soap:Body>
</soap:Envelope>
Here is the WSDL file defining the web service:
<definitions name="ACCOUNT_WS"
targetNamespace="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS" elementFormDefault="qualified">
<xsd:element name="CACCOUNT_A-GET_BY_ACCOUNT_NUMBERInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ACCOUNT_NUMBER-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GET_BY_ACCOUNT_NUMBEROutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="GET_BY_ACCOUNT_NUMBERInputMessage">
<part name="parameters" element="tns:CACCOUNT_A-GET_BY_ACCOUNT_NUMBERInput"/>
</message>
<message name="GET_BY_ACCOUNT_NUMBEROutputMessage">
<part name="parameters" element="tns:GET_BY_ACCOUNT_NUMBEROutput"/>
</message>
<portType name="ACCOUNT_WSPortType">
<operation name="GET_BY_ACCOUNT_NUMBER">
<input message="tns:GET_BY_ACCOUNT_NUMBERInputMessage"/>
<output message="tns:GET_BY_ACCOUNT_NUMBEROutputMessage"/>
</operation>
</portType>
<binding name="ACCOUNT_WSBinding" type="tns:ACCOUNT_WSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GET_BY_ACCOUNT_NUMBER">
<soap:operation soapAction="GET_BY_ACCOUNT_NUMBER"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="ACCOUNT_WSService">
<documentation>Oracle Web Service</documentation>
<port name="ACCOUNT_WSPort" binding="tns:ACCOUNT_WSBinding">
<soap:address location="http://example.com:2222/orawsv/PS_API/ACCOUNT_WS"/>
</port>
</service>
</definitions>
Since you have the WSDL, you shouldn't have to construct SOAP::Data objects at all. Simply load the WSDL into your client object and call the method directly:
my $client = SOAP::WSDL->new(wsdl => $url_of_wsdl);
my $result = $client->$method(#arguments);
Yes, it's that easy!
Looks like this is about a year old, so this might not be relevant any longer. Anyway, based on the soap::lite documentation on CPAN it looks like you want to do this:
my $response = $sObj->call(SOAP::Data->name($method)->attr({ 'xmlns' => $method_urn}),
SOAP::Data->name('parameters')->value(SOAP::Data->value([
SOAP::Data->name('ACCOUNT_NUMBER-VARCHAR2-IN' => '274724'),
]))
);
die $response->fault->{ faultstring } if ($response->fault);
print $response->result, "\n";