Passing NSString argument to SOAP WS yields "Illegal processing instruction target ("xml")" - objective-c

I am invoking the WS using SudzC generated code:
[service createPendingSalesOrders:self action:#selector(handler:) arg0:
#"<?xml version='1.0'"
" encoding='utf-8'?>"
"<root>test</root>"];
The soap request is:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://com/">
<soapenv:Body>
<com:createPendingSalesOrders>
<arg0>"<?xml version='1.0' encoding='utf-8'?><root>test</root>"
</arg0>
</com:createPendingSalesOrders>
</soapenv:Body>
</soapenv:Envelope>
I am receiving:
[com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
from my WS running on glassfish.
The WS works with other XML strings that seem to contain the same PI.
Thanks for any insight,
Dane

If you insist on wrapping xml into xml, put the contents into CDATA section, so the parser would process it as a string.

Related

Sequence of parameters in Axis2 1.7.8

I am deploying a POJO as a service in axis 2 1.7.8 . Following is the method signature :
public String authenticate(String username, String password, String dName, String sName)
{
return authenticateWithRole(username, password, "", dName, sName);
}
I am skipping the wsdl generated part. Following is the Request SOAP as generated in SOAPUI :
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:lab="test_authenticate">
<soap:Header/>
<soap:Body>
<lab:authenticate>
<!--Optional:-->
<lab:username>a</lab:username>
<!--Optional:-->
<lab:password>b</lab:password>
<!--Optional:-->
<lab:dName>c</lab:dName>
<!--Optional:-->
<lab:sName>d</lab:sName>
</lab:authenticate>
</soap:Body>
</soap:Envelope>
The above SOAP works. If the sequence of the parameters is changed, things do not work. For example, if I send the 'sName' parameter as first parameters, the preceding parameter values are set to null :
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:lab="test_authenticate">
<soap:Header/>
<soap:Body>
<lab:authenticate>
<!--Optional:-->
<lab:sName>d</lab:sName>
<!--Optional:-->
<lab:username>a</lab:username>
<!--Optional:-->
<lab:password>b</lab:password>
<!--Optional:-->
<lab:dName>c</lab:dName>
</lab:authenticate>
</soap:Body>
</soap>
This means that the sequence of parameters matters in axis 2.
How do I change this so that the second SOAP also works and the client is not bound to send the parameters in fixed sequence.
Thanks
The problem was in the BeanUtils.deserialize of apache-adb library method. So if the parameters in are not sent in the order they are defined at the method level, parameters which are pushed back in the order are set to null.
Needs a code fix.

(Wso2 Api Manager 2.6.0) How to send a list of string as input using mediator?

(Wso2 Api Manager 2.6.0) How to send a list of string as input using mediator?
I have a Api and my api have a list of string for input.
my api is soap.
I think mediator can help me.
I want a mediator for this api.
for example this is my input:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:GetData>
<!--Optional:-->
<tem:value>
<!--Zero or more repetitions:-->
<arr:string>a</arr:string>
<arr:string>s</arr:string>
<arr:string>f</arr:string>
</tem:value>
</tem:GetData>
</soapenv:Body>
</soapenv:Envelope>
and this is my output
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetDataResponse xmlns="http://tempuri.org/">
<GetDataResult>You entered: a s f</GetDataResult>
</GetDataResponse>
</s:Body>
</s:Envelope>

Karate: XML - CDATA print not as an xml format

When I print response of the SOAP which has CDATA, it contains gt and lt as shown bellow. Can you please help to convert this to proper xml or can you help me to validate some of the value of the response.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:processRequestResponse xmlns:ns="http://controller.core.xxx.xxxxx.xxxx.xxxxxx.com">
<return><?xml version="1.0" encoding="UTF-8"?>
<xxx:xxxxxxxxxxxx xmlns:xxx="http://xxxxx.com/xxxx/xxxx/xxx/response/xyz/abc">
<Header><destinationId>ABC</destinationId>
..............
..............
...............
</Body>
</xxx:xxxxxxxxxxxxxResponse></return>
</ns:processRequestResponse>
</soapenv:Body>
</soapenv:Envelope>
I think one line will do the trick for you, try this:
* xml temp = $response//return

Is there some example xml for the FormInfo list for the updateCredentialsForItem1?

I have been receiving the following error when trying to post updated login credentials:
<Exception>org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Can not invoke the getTypeObject method in the extension mapper class...
I am accessing the SOAP API via a rails app using the savon gem.
addItemForContentService is working with the same xsi:type definition, and I have used getLoginFormCredentialsForItem to retrieve FormInfos to push back into updateCredentialsForItem1, with no success.
If I could just get some sample xml (that works) for this call I would really appreciate it.
It seems like the parameters you are sending are incorrect or the WSDL format.
For your reference below is XML for updateCredentialsForItem1(you need to change values):
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<updateCredentialsForItem1 xmlns="http://itemmanagement.accountmanagement.core.soap.yodlee.com">
<userContext xmlns="">
<cobrandId>134131232</cobrandId>
<channelId>-1</channelId>
<locale>
<country>US</country>
<language>en</language>
<variant></variant>
</locale>
<tncVersion>2</tncVersion>
<applicationId>7A367HGJ621219F00</applicationId>
<cobrandConversationCredentials xsi:type="ns1:SessionCredentials" xmlns:ns1="http://login.ext.soap.yodlee.com">
<sessionToken>YOUR_COBRAND_CONVERSATION_TOKEN_VALUE</sessionToken>
</cobrandConversationCredentials>
<preferenceInfo>
<currencyCode>USD</currencyCode>
<timeZone>PST</timeZone>
<dateFormat>MM/dd/yyyy</dateFormat>
<currencyNotationType>SYMBOL_NOTATION</currencyNotationType>
<numberFormat>
<decimalSeparator>.</decimalSeparator>
<groupingSeparator>,</groupingSeparator>
<groupPattern>###,##0.##</groupPattern>
</numberFormat>
</preferenceInfo>
<fetchAllLocaleData>false</fetchAllLocaleData>
<conversationCredentials xsi:type="ns2:SessionCredentials" xmlns:ns2="http://login.ext.soap.yodlee.com">
<sessionToken>USER_CONVERSATION_TOKEN_VALUE</sessionToken>
</conversationCredentials>
<valid>true</valid>
<isPasswordExpired>false</isPasswordExpired>
</userContext>
<itemId xmlns="">1219123123</itemId>
<credentialFields xmlns="">
<elements xsi:type="ns3:SecureFieldInfoSingle" xmlns:ns3="http://common.soap.yodlee.com">
<name>LOGIN</name>
<displayName>Username</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>2212059</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_USERNAME</value>
<valueIdentifier>LOGIN</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>TEXT</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns4:SecureFieldInfoSingle" xmlns:ns4="http://common.soap.yodlee.com">
<name>PASSWORD1</name>
<displayName>Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns5:FieldInfoSingle" xmlns:ns5="http://common.soap.yodlee.com">
<name></name>
<displayName>Verify Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
</credentialFields>
<startRefreshItemOnUpdate xmlns="">false</startRefreshItemOnUpdate>
</updateCredentialsForItem1>
</soapenv:Body>
</soapenv:Envelope>

WCF request with default empty tags

I'm trying to connect to a SOAP 1.1 webservice, using TLS.
The certificate has been set up right, and I am able to communicate with the webservice.
However, when I try to do this using a plain C# project, using proxyclasses generated by VS2010, the request seems to be incomplete, as in, the empty tags are not in the request. I then get a "This is an operation implementation generated fault" fault, viewable in Fiddler
If I then try to launch a request using SoapUI, I get a succesful response from the webservice.
I used Fiddler to compare both requests, and I noticed that the C# request was pretty plain, only sending elements that were filled in in my C# class.
But when I check the SoapUI request, this request included EVERY element defined in the WSDL/XSD's, even though they're empty.
I'm trying to understand how I can configure the C# client to include empty elements, to see if the webservice will accept my request, however I was unable to find such setting.
The C# request response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode xmlns="">
SOAP-ENV:Server
</faultcode>
<faultstring xmlns="">
This is an operation implementation generated fault
</faultstring>
<faultactor xmlns=""/>
<detail xmlns="">
<ns:SOAPFault xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:xxx:xxx:data:soapfault:1:standard" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<ns:ErrorCode>2.0</ns:ErrorCode>
<ns:ErrorText>XML schema validation error</ns:ErrorText>
<ns:ErrorDetails>
/{urn:xxx:xxx:service:contractcancellation:1:standard}ContractCancellationRequestEnvelope[1]/part1[1]/ContractCancellationRequestEnvelope[1]/BusinessDocumentHeader[1]/Destination[1]
</ns:ErrorDetails>
</ns:SOAPFault>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The C# request:
POST xx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:ContractCancellationRequestEnvelope"
Host: xx
Content-Length: 887
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ContractCancellationRequestEnvelope xmlns="urn:xxx:xxx:data:contractcancellationrequest:1:standard">
<Portaal_Content>
<Portaal_MeteringPoint>
<EANID>xxx</EANID>
<MPCommercialCharacteristics>
<ContractCancellationDate>
2013-11-15
</ContractCancellationDate>
</MPCommercialCharacteristics>
<Portaal_Mutation>
<Initiator>xxx</Initiator>
<Dossier>
<ID>TST0000001</ID>
</Dossier>
</Portaal_Mutation>
</Portaal_MeteringPoint>
</Portaal_Content>
</ContractCancellationRequestEnvelope>
</s:Body>
</s:Envelope>
The SoapUI request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xxx:xxx:data:contractcancellationrequest:1:standard">
<soapenv:Header/>
<soapenv:Body>
<urn:ContractCancellationRequestEnvelope>
<urn:BusinessDocumentHeader>
<!--Optional:-->
<urn:ContentHash>?</urn:ContentHash>
<!--Optional:-->
<urn:ConversationID>?</urn:ConversationID>
<!--Optional:-->
<urn:CorrelationID>?</urn:CorrelationID>
<urn:CreationTimestamp>?</urn:CreationTimestamp>
<!--Optional:-->
<urn:DocumentID>?</urn:DocumentID>
<!--Optional:-->
<urn:ExpiresAt>?</urn:ExpiresAt>
<urn:MessageID>?</urn:MessageID>
<!--Optional:-->
<urn:ProcessTypeID>?</urn:ProcessTypeID>
<!--Optional:-->
<urn:RepeatedRequest>?</urn:RepeatedRequest>
<!--Optional:-->
<urn:TestRequest>?</urn:TestRequest>
<urn:Destination>
<urn:Receiver>
<!--Optional:-->
<urn:Authority>?</urn:Authority>
<!--Optional:-->
<urn:ContactTypeIdentifier>?</urn:ContactTypeIdentifier>
<urn:ReceiverID>?</urn:ReceiverID>
</urn:Receiver>
<!--Optional:-->
<urn:Service>
<!--Optional:-->
<urn:ServiceMethod>?</urn:ServiceMethod>
<!--Optional:-->
<urn:ServiceName>?</urn:ServiceName>
</urn:Service>
</urn:Destination>
<!--Optional:-->
<urn:Manifest>
<urn:NumberofItems>?</urn:NumberofItems>
<!--1 or more repetitions:-->
<urn:ManifestItem>
<!--Optional:-->
<urn:Description>?</urn:Description>
<!--Optional:-->
<urn:LanguageCode>?</urn:LanguageCode>
<urn:MimeTypeQualifierCode>?</urn:MimeTypeQualifierCode>
<urn:UniformResourceIdentifier>?</urn:UniformResourceIdentifier>
</urn:ManifestItem>
</urn:Manifest>
<urn:Source>
<!--Optional:-->
<urn:Authority>?</urn:Authority>
<!--Optional:-->
<urn:ContactTypeIdentifier>?</urn:ContactTypeIdentifier>
<urn:SenderID>?</urn:SenderID>
</urn:Source>
</urn:BusinessDocumentHeader>
<urn:Portaal_Content>
<urn:Portaal_MeteringPoint>
<urn:EANID>?</urn:EANID>
<urn:MPCommercialCharacteristics>
<urn:ContractCancellationDate>?</urn:ContractCancellationDate>
</urn:MPCommercialCharacteristics>
<urn:Portaal_Mutation>
<!--Optional:-->
<urn:ExternalReference>?</urn:ExternalReference>
<urn:Initiator>?</urn:Initiator>
<!--Optional:-->
<urn:Dossier>
<urn:ID>?</urn:ID>
</urn:Dossier>
</urn:Portaal_Mutation>
</urn:Portaal_MeteringPoint>
</urn:Portaal_Content>
</urn:ContractCancellationRequestEnvelope>
</soapenv:Body>
</soapenv:Envelope>
As you can see, the SoapUI request is far more complete, even though the elements are empty.
C# code (important parts):
_binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
_binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
_endpoint = new EndpointAddress(endpointAddress + "xxx");
_proxy = new ContractCancellationPortTypeClient(_binding, _endpoint);
_proxy.ClientCredentials.ClientCertificate.SetCertificate(
StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindBySubjectName,
"xxx");
_proxy.ContractCancellation(new ContractCancellationRequestEnvelope()
{ Portaal_Content = new ContractCancellationRequestEnvelope_PC()
{ Portaal_MeteringPoint = new ContractCancellationRequestEnvelope_PC_PMP()
{ EANID = request.EanId,
MPCommercialCharacteristics = new ContractCancellationRequestEnvelope_PC_PMP_MPCC()
{ ContractCancellationDate = request.ContractCancellationDate },
Portaal_Mutation = new ContractCancellationRequestEnvelope_PC_PMP_PM()
{ Initiator = request.SupplierEanId,
Dossier = new ContractCancellationRequestEnvelope_PC_PMP_PM_Dossier()
{ ID = "TST0000001" }
}
}
});
In your code, you're generating the Portaal_Content portion of the ContractCancellationRequestEnvelope, but not the BusinessDocumentHeader portion.
If you look at the fault received (via C#) I'm betting that there's one or more required elements in the BusinessDocumentHeader section that are missing:
The error text is XML schema validation error, and the error detail is:
ContractCancellationRequestEnvelope[1]/part1[1]/ContractCancellationRequestEnvelope[1]/BusinessDocumentHeader[1]/Destination[1]
You need to ensure that all required elements are present in your SOAP message.
EDIT
Something like this should do the trick:
ContractCancellationRequestEnvelope reqMsg = new ContractCancellationRequestEnvelope();
reqMsg.BusinessDocumentHeader = new BusinessDocumentHeader()
{ CorrelationTimestamp = "?",
MessageID = "?" };
reqMsg.BusinessDocumentHeader.Destination = new Destination();
reqMsg.BusinessDocumentHeader.Receiver = new Receiver()
{ ReceiverID = "?" };
And so on. Basically, make sure that you create every element that is required.
By the way, you can do nested automatic initialization (as in the code you posted), I simply took a more explicit route in my example for readability.
The service's WSDL will tell you what is required or optional.
If you need more help either provide the URL for the service or post the WSDL.