lawson / infor web services: only accepts soap 1.1 messages (not soap 1.2) so use the old school web services link to create the web service reference.
how to call a service:
//// ----------------------- //// below this line is copy-and-pasteable with the other section - but change prod to test M3CustomProd.ItemOperationsService s = createWebServiceClientProd(user, password); M3CustomProd.ct_0 i = new M3CustomProd.ct_0(); i.ItemNumber = itemNumber; i.RelatedItem = relatedItem; i.ReplacementType = replacementType.ToString(); i.StartDate = startDate.ToString("ddMMyy"); var lws = new M3CustomProd.lws(); var sst = new M3CustomProd.SupersessionsType(); sst.MMS020 = i; //var req = new M3CustomProd.SupersessionsResponseType(lws, sst); M3CustomProd.SupersessionsResponseType response = null; try { response = s.Supersessions(sst); result = response.ToString(); if (result.EndsWith(".SupersessionsResponseType")) { //result = String.Format("Successfully related: {0} > {1} (type {2})", itemNumber, relatedItem, replacementType); // in an effort to keep the output simple don't return anything here result = ""; } } catch (SoapHeaderException fe) { switch (fe.Code.Name) { case "M3-4": result = String.Format("Relationship already exists: {0} > {1} (type {2})", itemNumber, relatedItem, replacementType); break; default: result = fe.Message; break; } } catch (Exception fe) { result = fe.Message; }
and this to send authentication
private M3CustomProd.ItemOperationsService createWebServiceClientProd(string user, string password) { M3CustomProd.ItemOperationsService result = null; BasicHttpBinding bhbServiceReference = new BasicHttpBinding(); bhbServiceReference.Name = "m3PROD"; //name not used bhbServiceReference.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; bhbServiceReference.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; bhbServiceReference.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; bhbServiceReference.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; bhbServiceReference.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; result = (new M3CustomProd.ItemOperationsService()); result.Credentials = new NetworkCredential() { UserName= user, Password= password }; return (result); }
have this in app settings:
<add key="M3CustomTest.ItemOperationsService" value="http://cpxaklm3.corp.clientname.co.nz:21005/lws-ws/LWS_TEST/ItemOperations"/>
<add key="M3CustomProd.ItemOperationsService" value="http://cpxaklm3.corp.clientname.co.nz:19005/lws-ws/LWS_PROD/ItemOperations"/>
How to add soap v1.1 web service (as opposed to soap 1.2)
Leave a Comment
Comments