Hello everyone.
I've been trying to request my WCF Service from my b4a App but I couldn't establish connection.
I traced my service and I could get a "template" for the request (I added a xml file in folder assets (mytemp.xml):
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns: s="http://www.w3.org/2003/05/soap-envelope" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDjskkaIkLpaslasAAAA+kPzZSz+2UKCWp7tDBq2JBDnUJSMAM7jsjakaksmKKquqahsh</VsDebuggerCausalityData>
<o:Security s:mustUnderstand="1" xmlns: o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2013-03-13T21:45:31.175Z</u:Created>
<u:Expires>2013-03-13T21:50:31.175Z</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="uuid-47e0fgcd-e4g4-2e53-8df9-5e564777g112f-1">
<o:Username>myusername</o:Username>
<oassword>mypassword</oassword>
</o:UsernameToken>
</o:Security>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.mypublicsite.com/HelloWorldService.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/HelloWorldService/SayHelloWorld</Action>
</s:Header>
<s:Body><SayHelloWorld xmlns="http://tempuri.org/"><HelloWorldType xmlns:a="http://schemas.datacontract.org/2004/07/WcfService1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:Language>English</a:Language><a:Name>Michael</a:Name></HelloWorldType></SayHelloWorld></s:Body>
</s:Envelope>
After that, I tried to request from my App using this code (to test I didn't change username and password and I used them as in the template):
I've been trying different ways to make the request but I get the message "Error: Bad Request". I think the problem is this tag:
<o:UsernameToken u:Id="uuid-47e0fgcd-e4g4-2e53-8df9-5e564777g112f-1">
Because it's different when I make a new request (I've checked debugging in Visual Studio) but I'm not sure what is the correct way to make a request in this scenario.
I hope you can help me.
Thanks in advance.
I've been trying to request my WCF Service from my b4a App but I couldn't establish connection.
I traced my service and I could get a "template" for the request (I added a xml file in folder assets (mytemp.xml):
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns: s="http://www.w3.org/2003/05/soap-envelope" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDjskkaIkLpaslasAAAA+kPzZSz+2UKCWp7tDBq2JBDnUJSMAM7jsjakaksmKKquqahsh</VsDebuggerCausalityData>
<o:Security s:mustUnderstand="1" xmlns: o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2013-03-13T21:45:31.175Z</u:Created>
<u:Expires>2013-03-13T21:50:31.175Z</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="uuid-47e0fgcd-e4g4-2e53-8df9-5e564777g112f-1">
<o:Username>myusername</o:Username>
<oassword>mypassword</oassword>
</o:UsernameToken>
</o:Security>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.mypublicsite.com/HelloWorldService.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/HelloWorldService/SayHelloWorld</Action>
</s:Header>
<s:Body><SayHelloWorld xmlns="http://tempuri.org/"><HelloWorldType xmlns:a="http://schemas.datacontract.org/2004/07/WcfService1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:Language>English</a:Language><a:Name>Michael</a:Name></HelloWorldType></SayHelloWorld></s:Body>
</s:Envelope>
After that, I tried to request from my App using this code (to test I didn't change username and password and I used them as in the template):
B4X:
Sub Globals
Dim template As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout")
template = File.ReadString(File.DirAssets, "mytemp.xml")
Dim job As HttpJob
job.Initialize("Job", Me)
job.PostString("http://www.mypublicsite.com/HelloWorldService.svc", template)
job.GetRequest.SetContentType("application/soap+xml; charset=utf-8")
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Msgbox(Job.GetString(), "")
parser.Initialize
'Parsing the xml result
Dim In As InputStream
In = Job.GetInputStream
parser.Parse(In, "Parser")
In.Close
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
I've been trying different ways to make the request but I get the message "Error: Bad Request". I think the problem is this tag:
<o:UsernameToken u:Id="uuid-47e0fgcd-e4g4-2e53-8df9-5e564777g112f-1">
Because it's different when I make a new request (I've checked debugging in Visual Studio) but I'm not sure what is the correct way to make a request in this scenario.
I hope you can help me.
Thanks in advance.