Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding a java class of a wsdl service
    primarykey
    data
    text
    <p>i am trying to write a test code of wsdl web service in java. This code return me some values of variables and have to place an order. Of this code i have en equivalent on C# but i don't understand how to convert in java. This is my code in Java:</p> <pre><code> package betdaqclient; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.xml.bind.JAXBElement; public class test { public static void main(String[] args) { ExternalApiHeader externalAPIHeader = new ExternalApiHeader(); externalAPIHeader.languageCode = "en"; externalAPIHeader.username = "myusername"; externalAPIHeader.password = "mypassword"; externalAPIHeader.version = new BigDecimal ("2.0"); ReadOnlyService_Service ro = new ReadOnlyService_Service(); ReadOnlyService readOnlyService = ro.getReadOnlyService(); SecureService_Service ss = new SecureService_Service(); SecureService secureService = ss.getSecureService(); GetAccountBalancesRequest getAccountBalanceRequest = new GetAccountBalancesRequest(); GetAccountBalancesResponse2 getAccountBalanceResponse = secureService.getAccountBalances(getAccountBalanceRequest, externalAPIHeader); System.out.printf("%n%nUser : " + externalAPIHeader.username); System.out.printf("%nBalance : " + getAccountBalanceResponse.balance.toString()); System.out.printf("%nExposure : " + getAccountBalanceResponse.exposure.toString()); System.out.printf("%nAvailable: " + getAccountBalanceResponse.availableFunds.toString()+"%n"); SimpleOrderRequest bet = new SimpleOrderRequest(); bet.selectionId = (long) IdMarket; bet.polarity = (byte) 1 ; //&lt;-----BACK? bet.stake = new BigDecimal("1.00") ; bet.price = new BigDecimal("1.01") ; bet.cancelOnInRunning = true ; PlaceOrdersNoReceiptRequest request = new PlaceOrdersNoReceiptRequest(); /* Lacking Code */ PlaceOrdersNoReceiptResponse2 response = secureService.placeOrdersNoReceipt(request,externalAPIHeader); } } </code></pre> <p>I guess that my <code>bet</code> has to be converted in a list and then passed to <code>request</code>. This is the code in C# that i have found in the examples:</p> <pre><code> public long[] PlaceOrdersNoReceipt(long selectionId, byte polarity, decimal amount , decimal odds, byte resetCount) { SimpleOrderRequest order = new SimpleOrderRequest(); order.SelectionId = selectionId; order.Polarity = polarity; order.Stake = amount; order.Price = odds; order.ExpectedSelectionResetCount = resetCount; PlaceOrdersNoReceiptRequest request = new PlaceOrdersNoReceiptRequest(); request.Orders = new SimpleOrderRequest[1] {order}; PlaceOrdersNoReceiptResponse response = _proxy.PlaceOrdersNoReceipt(request); if (response.ReturnStatus.Code != 0) throw new Exception(response.ReturnStatus.Description); return response.OrderHandles; } </code></pre> <p>This is the definition of the class built from wsdl:</p> <pre><code>@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "PlaceOrdersNoReceiptRequest", propOrder = { "orders", "wantAllOrNothingBehaviour" }) public class PlaceOrdersNoReceiptRequest { @XmlElement(name = "Orders", required = true) protected PlaceOrdersNoReceiptRequest.Orders orders; @XmlElement(name = "WantAllOrNothingBehaviour") protected boolean wantAllOrNothingBehaviour; public PlaceOrdersNoReceiptRequest.Orders getOrders() {return orders;} public void setOrders(PlaceOrdersNoReceiptRequest.Orders value) {this.orders = value;} public boolean isWantAllOrNothingBehaviour() { return wantAllOrNothingBehaviour; } public void setWantAllOrNothingBehaviour(boolean value) {this.wantAllOrNothingBehaviour = value;} @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = {"order"}) public static class Orders { @XmlElement(name = "Order", required = true) protected List&lt;SimpleOrderRequest&gt; order; public List&lt;SimpleOrderRequest&gt; getOrder() { if (order == null) { order = new ArrayList&lt;SimpleOrderRequest&gt;(); } return this.order; } } } </code></pre> <p>The question is how i have to convert <code>bet</code> element of thee class <code>SimpleOrderRequest</code> into <code>request</code> of the class <code>PlaceOrderNoRecepeit</code> ? May be a very stupid question but i am a newbie in java programming.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload