Copy link to clipboard
Copied
I am trying to add a product to an ecommerce site with this soap action: Product_UpdateInsert
I have followed this very brief instruction: https://jollyrogers.worldsecuresystems.com/catalystwebservice/catalystecommercewebservice.asmx?op=Pr...
I have a html page in a secure area with a jQuery ajax soap script.
I get the this error when I run the script:
<?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><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Server did not recognize the value of HTTP Header SOAPAction: https://jollyrogers.worldsecuresystems.com/CatalystDeveloperService/CatalystEcommerceWebservice/Prod....</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
I have also tried to add a header with the Soap action with the beforeSend in the ajax call.
This must have been solved before I suppose?
Here is my script:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test SOAP Request</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
<script type="text/javascript" src="//cdn.worldsecuresystems.com/bcapi/bcapi-0.0.1.min.js"></script>
</head>
<body>
<script>
var wsUrl = "https://jollyrogers.worldsecuresystems.com/catalystwebservice/catalystecommercewebservice.asmx";
var soapRequest =
'<?xml version="1.0" encoding="utf-8"?> \
<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> \
<Product_UpdateInsert xmlns="https://jollyrogers.worldsecuresystems.com/CatalystDeveloperService/CatalystEcommerceWebservice"> \
<username>myEmailAdress</username> \
<password>mySecretPassw</password> \
<siteId>1894001</siteId> \
<productList> \
<Products> \
<productCode>ZJAWEyuuyN</productCode> \
<productName>My test product</productName> \
<description>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</description> \
<smallImage>/images/product1/small.jpg</smallImage> \
<largeImage>/images/product1/large.jpg</largeImage> \
<cataloguesArray> \
<string>/Store/</string> \
</cataloguesArray> \
<pricesSaleArray> \
<string>US/19.95,3/17.96,7/16.96</string> \
</pricesSaleArray> \
<pricesRetailArray> \
<string>US/20,5/19,8/20</string> \
</pricesRetailArray> \
<pricesWholesaleArray> \
<string>US/20,5/19,8/20</string> \
</pricesWholesaleArray> \
<wholesaleTaxCodeArray> \
<string>US/0.00</string> \
</wholesaleTaxCodeArray> \
<taxCodeArray> \
<string>GB/VAT</string> \
</taxCodeArray> \
<groupProducts> \
<string>580H0036BL</string> \
<string>ACAI60</string> \
<string>ABC-123</string> \
</groupProducts> \
<groupProductsDescriptions> \
<string>Lorem ipsum dolor sit amet</string> \
<string>consectetur adipisicing elit</string> \
</groupProductsDescriptions> \
<supplierEntityId>1234</supplierEntityId> \
<supplierCommission>0</supplierCommission> \
<weight>30</weight> \
<tags>NEW!</tags> \
<unitType>string</unitType> \
<minUnits>0</minUnits> \
<maxUnits>2</maxUnits> \
<inStock>43</inStock> \
<onOrder>3</onOrder> \
<reOrder>2</reOrder> \
<inventoryControl>true</inventoryControl> \
<canPreOrder>true</canPreOrder> \
<custom1>Text in custom field 1</custom1> \
<custom2>Text in custom field 2</custom2> \
<custom3>Text in custom field 3</custom3> \
<custom4>Text in custom field 4</custom4> \
<popletImages>/images/image1.jpg;/images/image2.jpg;</popletImages> \
<enabled>true</enabled> \
<deleted>false</deleted> \
<captureDetails>true</captureDetails> \
<downloadLimitCount>20</downloadLimitCount> \
<limitDownloadsToIP>0</limitDownloadsToIP> \
<isOnSale>true</isOnSale> \
<hideIfNoStock>true</hideIfNoStock> \
<productAttributes>Size*|5|Y:L||UK/2|US/20,S||UK/1|US/10</productAttributes> \
<isGiftVoucher>false</isGiftVoucher> \
<enableDropShipping>true</enableDropShipping> \
<productWeight>0</productWeight> \
<productWidth>0</productWidth> \
<productHeight>0</productHeight> \
<productDepth>0</productDepth> \
<excludeFromSearch>false</excludeFromSearch> \
<productTitle>My product title</productTitle> \
<cycletypeId>3</cycletypeId> \
<cycletypeCount>-1</cycletypeCount> \
<slug>my-product</slug> \
<hasVariations>true</hasVariations> \
<variations> \
<ProductVariation xsi:nil="true" /> \
<ProductVariation xsi:nil="true" /> \
</variations> \
</Products> \
</productList> \
</Product_UpdateInsert> \
</soap12:Body> \
</soap12:Envelope>';
$.ajax({
type: "POST",
beforeSend: function(xhr){xhr.setRequestHeader('SOAPAction', 'https://jollyrogers.worldsecuresystems.com/CatalystDeveloperService/CatalystEcommerceWebservice/Prod...},
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: processSuccess,
error: processError
});
function processSuccess(data, status, req)
{
if (status == "success")
alert("Success!");
}
function processError(data, status, req)
{
alert("Failed!");
alert(req.responseText + " " + status);
}
</script>
</body>
</html>
This line is a target namespace so it should not be changed: <Product_Retrieve xmlns="http://tempuri.org/CatalystDeveloperService/CatalystEcommerceWebservice"> It is very easy to think that it's a placeholder and that it should be replaced with your own url, which it should not and which will fail.
This works now:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test 7 SOAP Request</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
</head
...Copy link to clipboard
Copied
This line is a target namespace so it should not be changed: <Product_Retrieve xmlns="http://tempuri.org/CatalystDeveloperService/CatalystEcommerceWebservice"> It is very easy to think that it's a placeholder and that it should be replaced with your own url, which it should not and which will fail.
This works now:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test 7 SOAP Request</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<script>
var SoapMessage = '<?xml version="1.0" encoding="utf-8"?> \
<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> \
<Product_Retrieve xmlns="http://tempuri.org/CatalystDeveloperService/CatalystEcommerceWebservice"> \
<username>Your Email</username> \
<password>Your password</password> \
<siteId>1894001</siteId> \
<productCode>HHKDKXS5MB</productCode> \
</Product_Retrieve> \
</soap12:Body> \
</soap12:Envelope>';
var url = "https://jollyrogers.worldsecuresystems.com/catalystwebservice/catalystecommercewebservice.asmx";
$.support.cors = true;
$.ajax({
type: "POST",
url: url,
data: SoapMessage,
dataType: "xml",
processData: true,
contentType: "text/xml; charset=\"utf-8\"",
success: function (msg) {
alert("suc: " + msg);
},
error: function (msg) {
alert("Failed: " + msg);
}
});
</script>
</body>
</html>
Copy link to clipboard
Copied
You plan to expose your admin username and password to everyone? Is this a public script?
Copy link to clipboard
Copied
Hi,
no it is in a secure area. I am checking if it is possible to only have a user with Users priviledge.
Copy link to clipboard
Copied
I created a new user role that can only add products. But I got a soap error: ERROR: You do not have enough privileges to add products
Copy link to clipboard
Copied
What happens with the admin username and password?
Copy link to clipboard
Copied
Happens? The user information is difficult to do anything with it is hard coded in the script unfortunately. I try to add a new user role with only add priviliedges. But it seems buggy.